/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*
* (C) Copyright IBM Corp. 1998, All Rights Reserved
*/
/**
* This class provides drawing and bounds-measurement of
* underlines. Additionally, it has a factory method for
* obtaining underlines from values of underline attributes.
*/
abstract class Underline {
/**
* Draws the underline into g2d. The thickness should be obtained
* from a LineMetrics object. Note that some underlines ignore the
* thickness parameter.
* The underline is drawn from (x1, y) to (x2, y).
*/
float thickness,
float x1,
float x2,
float y);
/**
* Returns the bottom of the bounding rectangle for this underline.
*/
/**
* Returns a Shape representing the underline. The thickness should be obtained
* from a LineMetrics object. Note that some underlines ignore the
* thickness parameter.
*/
float x1,
float x2,
float y);
// Implementation of underline for standard and Input Method underlines.
// These classes are private.
// IM Underlines ignore thickness param, and instead use
// DEFAULT_THICKNESS
// StandardUnderline's constructor takes a boolean param indicating
// whether to override the default thickness. These values clarify
// the semantics of the parameter.
private static final boolean USE_THICKNESS = true;
private static final boolean IGNORE_THICKNESS = false;
// Implementation of standard underline and all input method underlines
// except UNDERLINE_LOW_GRAY.
// the amount by which to move the underline
private float shift;
// the actual line thickness is this value times
// the requested thickness
private float thicknessMultiplier;
// if non-null, underline is drawn with a BasicStroke
// with this dash pattern
private float[] dashPattern;
// if false, all underlines are DEFAULT_THICKNESS thick
// if true, use thickness param
private boolean useThickness;
// cached BasicStroke
float thicknessMultiplier,
float[] dashPattern,
boolean useThickness) {
this.dashPattern = dashPattern;
this.useThickness = useThickness;
this.cachedStroke = null;
}
if (dashPattern == null) {
return new BasicStroke(lineThickness,
}
else {
return new BasicStroke(lineThickness,
10.0f,
0);
}
}
if (useThickness) {
return thickness * thicknessMultiplier;
}
else {
return DEFAULT_THICKNESS * thicknessMultiplier;
}
}
}
return stroke;
}
float thickness,
float x1,
float x2,
float y) {
}
}
float x1,
float x2,
float y) {
}
}
// Implementation of UNDERLINE_LOW_GRAY.
IMGrayUnderline() {
10.0f,
new float[] {1, 1},
0);
}
float thickness,
float x1,
float x2,
float y) {
}
return DEFAULT_THICKNESS * 2;
}
float x1,
float x2,
float y) {
return gp;
}
}
// Keep a map of underlines, one for each type
// of underline. The Underline objects are Flyweights
// (shared across multiple clients), so they should be immutable.
// If this implementation changes then clone underline
// instances in getUnderline before returning them.
static {
}
/**
* Return the Underline for the given value of
* TextAttribute.INPUT_METHOD_UNDERLINE or
* TextAttribute.UNDERLINE.
* If value is not an input method underline value or
* TextAttribute.UNDERLINE_ON, null is returned.
*/
return null;
}
}
}
}