reversedBoundsIntervals = new double[3];
}
+ public Transformation getCurrentProjection(Axes axes) throws DegenerateMatrixException {
+ DrawingTools drawingTools = visitor.getDrawingTools();
+ Canvas canvas = visitor.getCanvas();
+ Transformation zoneProjection = computeZoneProjection(axes);
+ Transformation transformation = computeBoxTransformation(axes, canvas, false);
+ Transformation dataTransformation = computeDataTransformation(axes);
+ Transformation windowTrans = drawingTools.getTransformationManager().getWindowTransformation().getInverseTransformation();
+ Transformation current = zoneProjection.rightTimes(transformation);
+ current = current.rightTimes(dataTransformation);
+
+ return windowTrans.rightTimes(current);
+ }
+
/**
* Draw the given {@see Axes}.
* @param axes {@see Axes} to draw.
double[] matrix = transformation.getMatrix();
try {
return TransformationFactory.getScaleTransformation(
- matrix[2] < 0 ? 1 : -1,
- matrix[6] < 0 ? 1 : -1,
- matrix[10] < 0 ? 1 : -1
- );
+ matrix[2] < 0 ? 1 : -1,
+ matrix[6] < 0 ? 1 : -1,
+ matrix[10] < 0 ? 1 : -1
+ );
} catch (DegenerateMatrixException e) {
// Should never happen.
return TransformationFactory.getIdentity();
// Reverse data if needed.
Transformation transformation = TransformationFactory.getScaleTransformation(
- axes.getAxes()[0].getReverse() ? 1 : -1,
- axes.getAxes()[1].getReverse() ? 1 : -1,
- axes.getAxes()[2].getReverse() ? 1 : -1
- );
+ axes.getAxes()[0].getReverse() ? 1 : -1,
+ axes.getAxes()[1].getReverse() ? 1 : -1,
+ axes.getAxes()[2].getReverse() ? 1 : -1
+ );
// Scale data.
Transformation scaleTransformation = TransformationFactory.getScaleTransformation(
- 2.0 / (bounds[1] - bounds[0]),
- 2.0 / (bounds[3] - bounds[2]),
- 2.0 / (bounds[5] - bounds[4])
- );
+ 2.0 / (bounds[1] - bounds[0]),
+ 2.0 / (bounds[3] - bounds[2]),
+ 2.0 / (bounds[5] - bounds[4])
+ );
transformation = transformation.rightTimes(scaleTransformation);
// Translate data.
Transformation translateTransformation = TransformationFactory.getTranslateTransformation(
- -(bounds[0] + bounds[1]) / 2.0,
- -(bounds[2] + bounds[3]) / 2.0,
- -(bounds[4] + bounds[5]) / 2.0
- );
+ -(bounds[0] + bounds[1]) / 2.0,
+ -(bounds[2] + bounds[3]) / 2.0,
+ -(bounds[4] + bounds[5]) / 2.0
+ );
transformation = transformation.rightTimes(translateTransformation);
return transformation;
}
drawingTools.getTransformationManager().useWindowCoordinate();
/* The Text object's rotation direction convention is opposite to the standard one, its angle is expressed in radians. */
- drawingTools.draw(texture, AnchorPosition.LOWER_LEFT, cornerPositions[0], -180.0*text.getFontAngle()/Math.PI);
+ drawingTools.draw(texture, AnchorPosition.LOWER_LEFT, cornerPositions[0], -180.0 * text.getFontAngle() / Math.PI);
drawingTools.getTransformationManager().useSceneCoordinate();
/* The text position vector before logarithmic scaling */
Vector3d unscaledTextPosition = new Vector3d(text.getPosition());
- boolean[] logFlags = new boolean[]{parentAxes.getXAxisLogFlag(), parentAxes.getYAxisLogFlag(), parentAxes.getZAxisLogFlag()};
+ boolean[] logFlags = new boolean[] {parentAxes.getXAxisLogFlag(), parentAxes.getYAxisLogFlag(), parentAxes.getZAxisLogFlag()};
/* Apply logarithmic scaling and then project */
Vector3d textPosition = ScaleUtils.applyLogScale(unscaledTextPosition, logFlags);
private double[] computeRatios(Transformation projection, Text text, Vector3d[] textBoxVectors, Dimension spriteDimension,
Dimension baseSpriteDimension) {
/* 1st element: ratio for the current texture, 2nd element: ratio for the unscaled texture */
- double[] ratios = new double[]{1.0, 1.0};
+ double[] ratios = new double[] {1.0, 1.0};
/* Ratios are relevant only to the filled text box mode */
if (text.getTextBoxMode() == 2) {
Axes parentAxes = (Axes) GraphicController.getController().getObjectFromId(parentAxesId);
/* Apply logarithmic scaling */
- boolean[] logFlags = new boolean[]{parentAxes.getXAxisLogFlag(), parentAxes.getYAxisLogFlag(), parentAxes.getZAxisLogFlag()};
+ boolean[] logFlags = new boolean[] {parentAxes.getXAxisLogFlag(), parentAxes.getYAxisLogFlag(), parentAxes.getZAxisLogFlag()};
textPosition = ScaleUtils.applyLogScale(textPosition, logFlags);
* Compute the final text box's and text's half-length vectors,
* using the rotated text label vectors.
*/
- revTextBoxWidth = textWidth.getNormalized().times(0.5*revTextBoxWidth.getX());
- revTextBoxHeight = textHeight.getNormalized().times(0.5*revTextBoxHeight.getY());
+ revTextBoxWidth = textWidth.getNormalized().times(0.5 * revTextBoxWidth.getX());
+ revTextBoxHeight = textHeight.getNormalized().times(0.5 * revTextBoxHeight.getY());
- textBoxWidth = textWidth.getNormalized().times(0.5*textBoxWidth.getX());
- textBoxHeight = textHeight.getNormalized().times(0.5*textBoxHeight.getY());
+ textBoxWidth = textWidth.getNormalized().times(0.5 * textBoxWidth.getX());
+ textBoxHeight = textHeight.getNormalized().times(0.5 * textBoxHeight.getY());
textWidth = textWidth.times(0.5);
textHeight = textHeight.times(0.5);
* Apparently uses the same convention as the texts (clockwise positive directions).
* To be verified.
*/
- Transformation projRotation = TransformationFactory.getRotationTransformation(180.0*fontAngle/Math.PI, 0.0, 0.0, 1.0);
+ Transformation projRotation = TransformationFactory.getRotationTransformation(180.0 * fontAngle / Math.PI, 0.0, 0.0, 1.0);
projCorners[0] = projPosition;
*/
private Vector3d[] computeCorners(Transformation projection, Vector3d[] projCorners, Axes parentAxes) {
Vector3d[] corners = new Vector3d[4];
- boolean[] logFlags = new boolean[]{parentAxes.getXAxisLogFlag(), parentAxes.getYAxisLogFlag(), parentAxes.getZAxisLogFlag()};
+ boolean[] logFlags = new boolean[] {parentAxes.getXAxisLogFlag(), parentAxes.getYAxisLogFlag(), parentAxes.getZAxisLogFlag()};
corners[0] = projection.unproject(projCorners[0]);
corners[1] = projection.unproject(projCorners[1]);
Vector3d[] projCorners = null;
DrawerVisitor currentVisitor = DrawerVisitor.getVisitor(text.getParentFigure());
- Transformation currentProj = currentVisitor.getAxesDrawer().getProjection(text.getParentAxes());
-
Axes parentAxes = (Axes) GraphicController.getController().getObjectFromId(text.getParentAxes());
- Dimension spriteDim = currentVisitor.getTextManager().getSpriteDims(currentVisitor.getColorMap(), text);
-
/* Compute the corners */
try {
+ Transformation currentProj = currentVisitor.getAxesDrawer().getCurrentProjection(parentAxes);
+
+ Dimension spriteDim = currentVisitor.getTextManager().getSpriteDims(currentVisitor.getColorMap(), text);
+
Vector3d[] textBoxVectors = currentVisitor.getTextManager().computeTextBoxVectors(currentProj, text, spriteDim, parentAxes);
Vector3d[] cornerPositions = currentVisitor.getTextManager().computeTextPosition(currentProj, text, textBoxVectors, spriteDim);
} else {
projCorners = currentVisitor.getTextManager().computeProjCorners(cornerPositions[0], text.getFontAngle(), spriteDim);
}
+
+ Vector3d[] corners = currentVisitor.getTextManager().computeCorners(currentProj, projCorners, parentAxes);
+ Double[] coordinates = currentVisitor.getTextManager().cornersToCoordinateArray(corners);
+
+ /* Set the computed coordinates */
+ text.setCorners(coordinates);
+
} catch (DegenerateMatrixException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
- Vector3d[] corners = currentVisitor.getTextManager().computeCorners(currentProj, projCorners, parentAxes);
- Double[] coordinates = currentVisitor.getTextManager().cornersToCoordinateArray(corners);
-
- /* Set the computed coordinates */
- text.setCorners(coordinates);
}
}