Commit 1e0cd7f6 authored by Nico Mack's avatar Nico Mack
Browse files

Changes required by move of CPS related Externalization entries into

dedicated CpsNamespace (TULIP-CPS) package
parent 9bd42244
ABOVE_ELEMENT=above
ACTIVATE_WITH_HANDLE_NODE=activateWithHandle ACTIVATE_WITH_HANDLE_NODE=activateWithHandle
ALPHA_NODE=alpha ALPHA_NODE=alpha
ANIMATED_PROPERTIES_ELEMENT=animatedProperties ANIMATED_PROPERTIES_ELEMENT=animatedProperties
...@@ -9,14 +8,12 @@ ASSIGNABLE_NODE=assignable ...@@ -9,14 +8,12 @@ ASSIGNABLE_NODE=assignable
BACKGROUND_COLOUR_NODE=backgroundColour BACKGROUND_COLOUR_NODE=backgroundColour
BASE_VALUE_NODE=baseValue BASE_VALUE_NODE=baseValue
BEGIN_NODE=begin BEGIN_NODE=begin
BELOW_ELEMENT=below
BEZEL_COLOUR_ELEMENT=bezelColour BEZEL_COLOUR_ELEMENT=bezelColour
BLOBS_NODE=blobs BLOBS_NODE=blobs
BORDER_THICKNESS_NODE=borderThickness BORDER_THICKNESS_NODE=borderThickness
BORDER_WIDTH_NODE=borderWidth BORDER_WIDTH_NODE=borderWidth
BOUNDS_NODE=bounds BOUNDS_NODE=bounds
BUILDER_CLASS_POSTFIX=Builder BUILDER_CLASS_POSTFIX=Builder
CAPPED_DISPLAY_NODE=cappedDisplay
CENTER_ON_ZOOM_NODE=centerOnZoom CENTER_ON_ZOOM_NODE=centerOnZoom
CENTRE_NODE=centre CENTRE_NODE=centre
CENTRED_NODE=centred CENTRED_NODE=centred
...@@ -84,17 +81,12 @@ LINE_WIDTH_NODE=lineWidth ...@@ -84,17 +81,12 @@ LINE_WIDTH_NODE=lineWidth
LOCATION_NODE=location LOCATION_NODE=location
LOOPING_NODE=looping LOOPING_NODE=looping
LOWER_BOUND_NODE=lowerBound LOWER_BOUND_NODE=lowerBound
LOWER_BOUND_VARIABLE_NODE=lowerBoundVariable
LOWER_STOP_ANGLE_NODE=lowerStopAngle
MAGNIFICATION_NODE=magnification MAGNIFICATION_NODE=magnification
MAGNIFIER_SHAPE_NODE=magnifierShape MAGNIFIER_SHAPE_NODE=magnifierShape
MARKER_BUILDER_NAMESPACE=lu.list.itis.dkd.tui.marker.builder MARKER_BUILDER_NAMESPACE=lu.list.itis.dkd.tui.marker.builder
MARKER_NODE=marker MARKER_NODE=marker
MARKERS_NODE=markers MARKERS_NODE=markers
MAXIMUM_VALUE_NODE=maximumValue
MEDIA_NODE=media MEDIA_NODE=media
MINIMUM_VALUE_NODE=minimumValue
MODIFY_VALUE_ON_ROTATION_NODE=modifyValueOnRotation
MULTIPLE_INSTANCES_NODE=multipleInstances MULTIPLE_INSTANCES_NODE=multipleInstances
NAME_ATTRIBUTE=name NAME_ATTRIBUTE=name
NAME_NODE=name NAME_NODE=name
...@@ -119,8 +111,6 @@ RADIUS_NODE=radius ...@@ -119,8 +111,6 @@ RADIUS_NODE=radius
RAMPING_TIME_NODE=rampingTime RAMPING_TIME_NODE=rampingTime
RECEIVER_NODE=receiver RECEIVER_NODE=receiver
RECEIVERS_NODE=receivers RECEIVERS_NODE=receivers
REFERENCE_NODE=reference
RELATIVE_NODE=relative
REPEAT_ATTRIBUTE=repeat REPEAT_ATTRIBUTE=repeat
REVERSING_NODE=reversing REVERSING_NODE=reversing
RGB_COLOUR_NODE=rgb RGB_COLOUR_NODE=rgb
...@@ -148,7 +138,6 @@ STAGESET_NODE=stageSet ...@@ -148,7 +138,6 @@ STAGESET_NODE=stageSet
START_ANGLE_NODE=startAngle START_ANGLE_NODE=startAngle
START_NODE=start START_NODE=start
STATE_NODE=state STATE_NODE=state
STEP_SIZE_NODE=stepSize
STOP_NODE=stop STOP_NODE=stop
STROKE_COLOUR_ELEMENT=strokeColour STROKE_COLOUR_ELEMENT=strokeColour
STROKE_WIDTH_NODE=strokeWidth STROKE_WIDTH_NODE=strokeWidth
...@@ -175,10 +164,6 @@ TRIGGERS_NODE=triggers ...@@ -175,10 +164,6 @@ TRIGGERS_NODE=triggers
TYPE_NODE=type TYPE_NODE=type
UNIT_NODE=unit UNIT_NODE=unit
UPPER_BOUND_NODE=upperBound UPPER_BOUND_NODE=upperBound
UPPER_BOUND_VARIABLE_NODE=upperBoundVariable
UPPER_STOP_ANGLE_NODE=upperStopAngle
VARIABLE_NODE=variable
VARIABLES_NODE=variables
VOLUME_NODE=volume VOLUME_NODE=volume
WIDGET_BUILDER_NAMESPACE=lu.list.itis.dkd.tui.widget.builder WIDGET_BUILDER_NAMESPACE=lu.list.itis.dkd.tui.widget.builder
WIDTH_NODE=width WIDTH_NODE=width
......
...@@ -405,7 +405,7 @@ public abstract class TangibleObjectManager { ...@@ -405,7 +405,7 @@ public abstract class TangibleObjectManager {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> List<T> getWidgets(Class<T> clazz) { public static synchronized <T> List<T> getWidgets(Class<T> clazz) {
List<T> results = new ArrayList<>(); List<T> results = new ArrayList<>();
for (BaseWidget widget : objectMap.values()) { for (BaseWidget widget : objectMap.values()) {
......
...@@ -32,6 +32,8 @@ import org.jdom2.Element; ...@@ -32,6 +32,8 @@ import org.jdom2.Element;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
/** /**
* @author Eric Tobias [eric.tobias@list.lu] * @author Eric Tobias [eric.tobias@list.lu]
...@@ -40,47 +42,7 @@ import java.lang.reflect.InvocationTargetException; ...@@ -40,47 +42,7 @@ import java.lang.reflect.InvocationTargetException;
*/ */
public class CoronaBootstrapper { public class CoronaBootstrapper {
/** // ---------------------------------------------------------------------------
* Method used to determine the appropriate builder for a given corona and then issue a build
* call.
*
* @param coronaNode
* The node from a larger document that contains, as children, all the necessary
* information to resolve the correct builder and build the final, concrete, corona.
* @return The final concrete corona as defined by the children of the element node.
* @throws ClassNotFoundException
* Thrown when the class of the builder for the corona could not be found.
* @throws SecurityException
* Thrown when the constructor cannot be retrieved due to some security constraints.
* @throws NoSuchMethodException
* Thrown when no constructor with the given parameter type is available.
* @throws InvocationTargetException
* Thrown if the invocation of any constructor through reflection throws an exception.
* @throws IllegalArgumentException
* Thrown when the provided argument is not eligible for the builder's constructor.
* @throws IllegalAccessException
* Thrown if this Constructor object is enforcing Java language access control and the
* underlying constructor is inaccessible.
* @throws InstantiationException
* Thrown if the class that declares the underlying constructor represents an abstract
* class.
* @throws BuildException
* Thrown if building the corona did not succeed due to an internal error such as a
* violation of precondition(s) or unavailable but required resources.
*/
// private static Corona getCorona(Element coronaNode) throws ClassNotFoundException,
// InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException,
// IllegalArgumentException, InvocationTargetException, BuildException {
// Element type = coronaNode.getChild(Externalization.TYPE_NODE);
// Class<?> builder = Class.forName(Externalization.CORONA_BUILDER_NAMESPACE +
// Externalization.NAMESPACE_SEPARATOR + type.getValue() +
// Externalization.BUILDER_CLASS_POSTFIX);
// @SuppressWarnings("unchecked")
// Constructor<CoronaBuilder<?>> constructor = (Constructor<CoronaBuilder<?>>)
// builder.getConstructor(new Class[] {Element.class});
// return constructor.newInstance(new Object[] {coronaNode}).build();
// }
/** /**
* Method used to determine the appropriate builder for a given object and then issue a build * Method used to determine the appropriate builder for a given object and then issue a build
* call. * call.
...@@ -111,6 +73,8 @@ public class CoronaBootstrapper { ...@@ -111,6 +73,8 @@ public class CoronaBootstrapper {
* class. * class.
* @throws BuildException * @throws BuildException
*/ */
// ---------------------------------------------------------------------------
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static Corona buildCoronaFromElement(Element coronaNode, BootstrapContext bootstrapContext, BootstrapCallback callback) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException, BuildException { public static Corona buildCoronaFromElement(Element coronaNode, BootstrapContext bootstrapContext, BootstrapCallback callback) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException, BuildException {
...@@ -130,6 +94,7 @@ public class CoronaBootstrapper { ...@@ -130,6 +94,7 @@ public class CoronaBootstrapper {
return instance; return instance;
} }
// ---------------------------------------------------------------------------
/** /**
* Method used for bootstrapping all coronas found as child nodes of a root node. The method * Method used for bootstrapping all coronas found as child nodes of a root node. The method
* will look for child nodes names <code>corona</code>. * will look for child nodes names <code>corona</code>.
...@@ -141,8 +106,9 @@ public class CoronaBootstrapper { ...@@ -141,8 +106,9 @@ public class CoronaBootstrapper {
* @throws BuildException * @throws BuildException
* Thrown when a corona was not associated to any handle. * Thrown when a corona was not associated to any handle.
*/ */
// ---------------------------------------------------------------------------
public static Multimap<Integer, Corona> getCoronas(Element coronaRootNode) throws BuildException { public static Multimap<Integer, Corona> getCoronas(Element coronaRootNode) throws BuildException {
// Multimap<Integer, Corona> coronas = TreeMultimap.create();
Multimap<Integer, Corona> coronas = ArrayListMultimap.create(); Multimap<Integer, Corona> coronas = ArrayListMultimap.create();
for (Element coronaNode : coronaRootNode.getChildren(Externalization.CORONA_NODE)) { for (Element coronaNode : coronaRootNode.getChildren(Externalization.CORONA_NODE)) {
...@@ -159,9 +125,11 @@ public class CoronaBootstrapper { ...@@ -159,9 +125,11 @@ public class CoronaBootstrapper {
return coronas; return coronas;
} }
// ---------------------------------------------------------------------------
/** /**
* Method used for bootstrapping all coronas found as child nodes of a root node. The method * Method used for bootstrapping all coronas found as child nodes of a root node. The method
* will look for child nodes names <code>corona</code>. * will look for child nodes names <code>corona</code>. The method returns a map, using the
* coronas' <code>handleId</code> property as the key and the corona itself as the value.
* *
* @param coronaRootNode * @param coronaRootNode
* The root node that holds all <code>corona</code> child nodes. * The root node that holds all <code>corona</code> child nodes.
...@@ -172,6 +140,8 @@ public class CoronaBootstrapper { ...@@ -172,6 +140,8 @@ public class CoronaBootstrapper {
* @throws BuildException * @throws BuildException
* Thrown when a corona was not associated to any handle. * Thrown when a corona was not associated to any handle.
*/ */
// ---------------------------------------------------------------------------
public static Multimap<Integer, Corona> getCoronas(Element coronaRootNode, BootstrapContext context, BootstrapCallback callback) throws BuildException { public static Multimap<Integer, Corona> getCoronas(Element coronaRootNode, BootstrapContext context, BootstrapCallback callback) throws BuildException {
Multimap<Integer, Corona> coronas = ArrayListMultimap.create(); Multimap<Integer, Corona> coronas = ArrayListMultimap.create();
...@@ -187,5 +157,36 @@ public class CoronaBootstrapper { ...@@ -187,5 +157,36 @@ public class CoronaBootstrapper {
return coronas; return coronas;
} }
// ---------------------------------------------------------------------------
/**
* Method used for bootstrapping all coronas found as child nodes of a root node. The method
* will look for child nodes names <code>corona</code>. The method returns a list of corona
* instances build from the definitions found under the coronaRootNode.
*
* @param coronaRootNode
* The root node that holds all <code>corona</code> child nodes.
* @param context
* @param callback
* @return A list containing all concrete {@link Corona} instances that could be build from the
* provided root node.
* @throws BuildException
* Thrown when a corona couldn't be build.
*/
// ---------------------------------------------------------------------------
public static List<Corona> getListOfCoronas(Element coronaRootNode, BootstrapContext context, BootstrapCallback callback) throws BuildException {
List<Corona> coronas = new ArrayList<>();
for (Element coronaNode : coronaRootNode.getChildren(Externalization.CORONA_NODE)) {
CoronaFactory<Corona> factory = new CoronaFactory<>(coronaNode, context, callback);
while (factory.hasNext()) {
Corona newInstance = factory.next();
coronas.add(newInstance);
}
}
return coronas;
}
} }
\ No newline at end of file
...@@ -126,6 +126,13 @@ public abstract class Marker implements Comparable<Marker> { ...@@ -126,6 +126,13 @@ public abstract class Marker implements Comparable<Marker> {
} }
} }
// ---------------------------------------------------------------------------
public @Nullable Point getPosition(Integer handleId) {
return positions.get(handleId);
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
public HashMap<Integer, Point> getPositions() { public HashMap<Integer, Point> getPositions() {
......
...@@ -3,7 +3,8 @@ package lu.list.itis.dkd.tui.utility; ...@@ -3,7 +3,8 @@ package lu.list.itis.dkd.tui.utility;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import java.awt.Color; import java.awt.Color;
import java.util.Vector; import java.util.ArrayList;
import java.util.List;
/** /**
* Color generator using three out of phase sine waves to produce a rainbow effect. see * Color generator using three out of phase sine waves to produce a rainbow effect. see
...@@ -72,14 +73,14 @@ public class ColorFactory { ...@@ -72,14 +73,14 @@ public class ColorFactory {
* *
* @return a vector containing the generated colors * @return a vector containing the generated colors
*/ */
public static Vector<Color> makeColorGradient(int number, float redFreq, float greenFreq, float blueFreq, public static List<Color> makeColorGradient(int number, float redFreq, float greenFreq, float blueFreq,
float redPhase, float greenPhase, float bluePhase, int center, int spread) { float redPhase, float greenPhase, float bluePhase, int center, int spread) {
Preconditions.checkArgument((center > 0) && (center < 255), "Center should be in the range 0 < center < 255"); //$NON-NLS-1$ Preconditions.checkArgument((center > 0) && (center < 255), "Center should be in the range 0 < center < 255"); //$NON-NLS-1$
Preconditions.checkArgument((spread > 0) && (spread < center), "Spread should be in the range 0 < spread < center"); //$NON-NLS-1$ Preconditions.checkArgument((spread > 0) && (spread < center), "Spread should be in the range 0 < spread < center"); //$NON-NLS-1$
Vector<Color> gradient = new Vector<>(number); List<Color> gradient = new ArrayList<>(number);
for (int i = 0; i < number; ++i) { for (int i = 0; i < number; ++i) {
int red = (int) (Math.sin(redFreq * i + redPhase) * spread + center); int red = (int) (Math.sin(redFreq * i + redPhase) * spread + center);
...@@ -100,7 +101,7 @@ public class ColorFactory { ...@@ -100,7 +101,7 @@ public class ColorFactory {
* specifies the number of colors to generate * specifies the number of colors to generate
* @return a vector containing the generated colors * @return a vector containing the generated colors
*/ */
public static Vector<Color> makeRainbowColours(int number) { public static List<Color> makeRainbowColours(int number) {
float frequency = (float) (Math.PI / number); float frequency = (float) (Math.PI / number);
return makeColorGradient(number, frequency, frequency, frequency, 0f, 2f, 4f, 128, 127); return makeColorGradient(number, frequency, frequency, frequency, 0f, 2f, 4f, 128, 127);
......
...@@ -33,7 +33,6 @@ import org.eclipse.osgi.util.NLS; ...@@ -33,7 +33,6 @@ import org.eclipse.osgi.util.NLS;
public class Externalization extends NLS { public class Externalization extends NLS {
private static final String BUNDLE_NAME = "externalization"; //$NON-NLS-1$ private static final String BUNDLE_NAME = "externalization"; //$NON-NLS-1$
public static String ABOVE_ELEMENT;
public static String ACTIVATE_WITH_HANDLE_NODE; public static String ACTIVATE_WITH_HANDLE_NODE;
public static String ALPHA_NODE; public static String ALPHA_NODE;
public static String ANIMATED_PROPERTIES_ELEMENT; public static String ANIMATED_PROPERTIES_ELEMENT;
...@@ -44,14 +43,12 @@ public class Externalization extends NLS { ...@@ -44,14 +43,12 @@ public class Externalization extends NLS {
public static String BACKGROUND_COLOUR_NODE; public static String BACKGROUND_COLOUR_NODE;
public static String BASE_VALUE_NODE; public static String BASE_VALUE_NODE;
public static String BEGIN_NODE; public static String BEGIN_NODE;
public static String BELOW_ELEMENT;
public static String BEZEL_COLOUR_ELEMENT; public static String BEZEL_COLOUR_ELEMENT;
public static String BLOBS_NODE; public static String BLOBS_NODE;
public static String BORDER_THICKNESS_NODE; public static String BORDER_THICKNESS_NODE;
public static String BORDER_WIDTH_NODE; public static String BORDER_WIDTH_NODE;
public static String BOUNDS_NODE; public static String BOUNDS_NODE;
public static String BUILDER_CLASS_POSTFIX; public static String BUILDER_CLASS_POSTFIX;
public static String CAPPED_DISPLAY_NODE;
public static String CENTER_ON_ZOOM_NODE; public static String CENTER_ON_ZOOM_NODE;
public static String CENTRE_NODE; public static String CENTRE_NODE;
public static String CENTRED_NODE; public static String CENTRED_NODE;
...@@ -119,17 +116,12 @@ public class Externalization extends NLS { ...@@ -119,17 +116,12 @@ public class Externalization extends NLS {
public static String LOCATION_NODE; public static String LOCATION_NODE;
public static String LOOPING_NODE; public static String LOOPING_NODE;
public static String LOWER_BOUND_NODE; public static String LOWER_BOUND_NODE;
public static String LOWER_BOUND_VARIABLE_NODE;
public static String LOWER_STOP_ANGLE_NODE;
public static String MAGNIFICATION_NODE; public static String MAGNIFICATION_NODE;
public static String MAGNIFIER_SHAPE_NODE; public static String MAGNIFIER_SHAPE_NODE;
public static String MARKER_BUILDER_NAMESPACE; public static String MARKER_BUILDER_NAMESPACE;
public static String MARKER_NODE; public static String MARKER_NODE;
public static String MARKERS_NODE; public static String MARKERS_NODE;
public static String MAXIMUM_VALUE_NODE;
public static String MEDIA_NODE; public static String MEDIA_NODE;
public static String MINIMUM_VALUE_NODE;
public static String MODIFY_VALUE_ON_ROTATION_NODE;
public static String MULTIPLE_INSTANCES_NODE; public static String MULTIPLE_INSTANCES_NODE;
public static String NAME_ATTRIBUTE; public static String NAME_ATTRIBUTE;
public static String NAME_NODE; public static String NAME_NODE;
...@@ -154,8 +146,6 @@ public class Externalization extends NLS { ...@@ -154,8 +146,6 @@ public class Externalization extends NLS {
public static String RAMPING_TIME_NODE; public static String RAMPING_TIME_NODE;
public static String RECEIVER_NODE; public static String RECEIVER_NODE;
public static String RECEIVERS_NODE; public static String RECEIVERS_NODE;
public static String REFERENCE_NODE;
public static String RELATIVE_NODE;
public static String REPEAT_ATTRIBUTE; public static String REPEAT_ATTRIBUTE;
public static String REVERSING_NODE; public static String REVERSING_NODE;
public static String RGB_COLOUR_NODE; public static String RGB_COLOUR_NODE;
...@@ -183,7 +173,6 @@ public class Externalization extends NLS { ...@@ -183,7 +173,6 @@ public class Externalization extends NLS {
public static String START_ANGLE_NODE; public static String START_ANGLE_NODE;
public static String START_NODE; public static String START_NODE;
public static String STATE_NODE; public static String STATE_NODE;
public static String STEP_SIZE_NODE;
public static String STOP_NODE; public static String STOP_NODE;
public static String STROKE_COLOUR_ELEMENT; public static String STROKE_COLOUR_ELEMENT;
public static String STROKE_WIDTH_NODE; public static String STROKE_WIDTH_NODE;
...@@ -210,10 +199,6 @@ public class Externalization extends NLS { ...@@ -210,10 +199,6 @@ public class Externalization extends NLS {
public static String TYPE_NODE; public static String TYPE_NODE;
public static String UNIT_NODE; public static String UNIT_NODE;
public static String UPPER_BOUND_NODE; public static String UPPER_BOUND_NODE;
public static String UPPER_BOUND_VARIABLE_NODE;
public static String UPPER_STOP_ANGLE_NODE;
public static String VARIABLE_NODE;
public static String VARIABLES_NODE;
public static String VOLUME_NODE; public static String VOLUME_NODE;
public static String WIDGET_BUILDER_NAMESPACE; public static String WIDGET_BUILDER_NAMESPACE;
public static String WIDTH_NODE; public static String WIDTH_NODE;
......
...@@ -45,6 +45,7 @@ public class TextStroke implements Stroke { ...@@ -45,6 +45,7 @@ public class TextStroke implements Stroke {
// *************************************************************************** // ***************************************************************************
// * Constants * // * Constants *
// *************************************************************************** // ***************************************************************************
private static final float FLATNESS = 1; private static final float FLATNESS = 1;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -105,7 +106,6 @@ public class TextStroke implements Stroke { ...@@ -105,7 +106,6 @@ public class TextStroke implements Stroke {
// * Class Body * // * Class Body *
// *************************************************************************** // ***************************************************************************
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** /**
* Controls whether the text is to be flipped, i.e. rendered upside down. * Controls whether the text is to be flipped, i.e. rendered upside down.
* *
...@@ -113,12 +113,13 @@ public class TextStroke implements Stroke { ...@@ -113,12 +113,13 @@ public class TextStroke implements Stroke {
* specify <code>true</code> to render text upside down, <code>false</code> if text is to * specify <code>true</code> to render text upside down, <code>false</code> if text is to
* be rendered normally * be rendered normally
*/ */
// ---------------------------------------------------------------------------
public void setFlipped(boolean flipIt) { public void setFlipped(boolean flipIt) {
this.flipped = flipIt; this.flipped = flipIt;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** /**
* renders the text using the font specified at construction time along the specified shape * renders the text using the font specified at construction time along the specified shape
* *
...@@ -126,11 +127,12 @@ public class TextStroke implements Stroke { ...@@ -126,11 +127,12 @@ public class TextStroke implements Stroke {
* specifies the shape to render the text along * specifies the shape to render the text along
* @return the rendered text following the specified path * @return the rendered text following the specified path
*/ */
// ---------------------------------------------------------------------------
@Override @Override
public Shape createStrokedShape(Shape shape) { public Shape createStrokedShape(Shape shape) {
FontRenderContext frc = new FontRenderContext(null, true, true); FontRenderContext frc = new FontRenderContext(null, true, true);
LineMetrics metrics = font.getLineMetrics(this.text, frc); LineMetrics metrics = font.getLineMetrics(text, frc);
GlyphVector glyphVector = font.createGlyphVector(frc, text); GlyphVector glyphVector = font.createGlyphVector(frc, text);
GeneralPath result = new GeneralPath(); GeneralPath result = new GeneralPath();
...@@ -152,8 +154,10 @@ public class TextStroke implements Stroke { ...@@ -152,8 +154,10 @@ public class TextStroke implements Stroke {
float lengthOfText = (float) glyphVector.getLogicalBounds().getWidth(); float lengthOfText = (float) glyphVector.getLogicalBounds().getWidth();
float factor = stretchToFit ? lengthOfPath / lengthOfText : 1.0f; float factor = stretchToFit ? lengthOfPath / lengthOfText : 1.0f;
float advance = (glyphVector.getNumGlyphs() > 0) ? glyphVector.getGlyphMetrics(0).getAdvance() : 0;
float offset = centered ? (1.2f * (lengthOfPath - lengthOfText)) / 2 : 0.0f; float offset = centered ? ((lengthOfPath - lengthOfText) / 2) : 0.0f;
// float offset = centered ? (1.2f * (lengthOfPath - lengthOfText)) / 2 : 0.0f;
// float offset = centered ? ((lengthOfPath - lengthOfText)) / 2: 0.0f; // float offset = centered ? ((lengthOfPath - lengthOfText)) / 2: 0.0f;
float nextAdvance = 0; float nextAdvance = 0;
...@@ -184,11 +188,11 @@ public class TextStroke implements Stroke { ...@@ -184,11 +188,11 @@ public class TextStroke implements Stroke {
float dy = thisY - lastY; float dy = thisY - lastY;
totX += Math.abs(dx); totX += Math.abs(dx);
totY += Math.abs(dy); totY += Math.abs(dy);
if (Math.sqrt(totX * totX + totY * totY) > offset) { if (Math.sqrt(totX * totX + totY * totY) >= offset) {
float distance = (float) Math.sqrt(dx * dx + dy * dy); float distance = (float) Math.sqrt(dx * dx + dy * dy);
if (distance >= next) { if (distance >= next) {
float r = 1.0f / distance; float r = 1.0f / distance;
float angle = (float) Math.atan2(dy, dx); double angle = Math.atan2(dy, dx);
while (currentChar < length && distance >= next) { while (currentChar < length && distance >= next) {
Shape glyph = glyphVector.getGlyphOutline(currentChar); Shape glyph = glyphVector.getGlyphOutline(currentChar);
Point2D p = glyphVector.getGlyphPosition(currentChar); Point2D p = glyphVector.getGlyphPosition(currentChar);
...@@ -199,7 +203,7 @@ public class TextStroke implements Stroke { ...@@ -199,7 +203,7 @@ public class TextStroke implements Stroke {
float x = lastX + next * dx * r; float x = lastX + next * dx * r;
float y = lastY + next * dy * r; float y = lastY + next * dy * r;
float advance = nextAdvance; advance = nextAdvance;