82 * @return baseline or a value < 0 indicating there is no reasonable
83 * baseline
84 * @see java.awt.FontMetrics
85 * @see javax.swing.JComponent#getBaseline(int,int)
86 * @since 1.6
87 */
88 public static int getHTMLBaseline(View view, int w, int h) {
89 if (w < 0 || h < 0) {
90 throw new IllegalArgumentException(
91 "Width and height must be >= 0");
92 }
93 if (view instanceof Renderer) {
94 return getBaseline(view.getView(0), w, h);
95 }
96 return -1;
97 }
98
99 /**
100 * Gets the baseline for the specified component. This digs out
101 * the View client property, and if non-null the baseline is calculated
102 * from it. Otherwise the baseline is the value <code>y + ascent</code>.
103 */
104 static int getBaseline(JComponent c, int y, int ascent,
105 int w, int h) {
106 View view = (View)c.getClientProperty(BasicHTML.propertyKey);
107 if (view != null) {
108 int baseline = getHTMLBaseline(view, w, h);
109 if (baseline < 0) {
110 return baseline;
111 }
112 return y + baseline;
113 }
114 return y + ascent;
115 }
116
117 /**
118 * Gets the baseline for the specified View.
119 */
120 static int getBaseline(View view, int w, int h) {
121 if (hasParagraph(view)) {
122 view.setSize(w, h);
|
82 * @return baseline or a value < 0 indicating there is no reasonable
83 * baseline
84 * @see java.awt.FontMetrics
85 * @see javax.swing.JComponent#getBaseline(int,int)
86 * @since 1.6
87 */
88 public static int getHTMLBaseline(View view, int w, int h) {
89 if (w < 0 || h < 0) {
90 throw new IllegalArgumentException(
91 "Width and height must be >= 0");
92 }
93 if (view instanceof Renderer) {
94 return getBaseline(view.getView(0), w, h);
95 }
96 return -1;
97 }
98
99 /**
100 * Gets the baseline for the specified component. This digs out
101 * the View client property, and if non-null the baseline is calculated
102 * from it. Otherwise the baseline is the value {@code y + ascent}.
103 */
104 static int getBaseline(JComponent c, int y, int ascent,
105 int w, int h) {
106 View view = (View)c.getClientProperty(BasicHTML.propertyKey);
107 if (view != null) {
108 int baseline = getHTMLBaseline(view, w, h);
109 if (baseline < 0) {
110 return baseline;
111 }
112 return y + baseline;
113 }
114 return y + ascent;
115 }
116
117 /**
118 * Gets the baseline for the specified View.
119 */
120 static int getBaseline(View view, int w, int h) {
121 if (hasParagraph(view)) {
122 view.setSize(w, h);
|