use of java.awt.geom.AffineTransform in project limelight by slagyr.
the class ImagePanelLayoutTest method getRotationTransformWhenDimensionsAreAuto.
@Test
public void getRotationTransformWhenDimensionsAreAuto() throws Exception {
panel.setFilename(TestUtil.DATA_DIR + "/star.gif");
panel.setRotation(45);
Layouts.on(panel, panel.getDefaultLayout());
AffineTransform tranform = panel.getTransform();
// No good way to test rotation....
assertEquals(141.0, tranform.getTranslateX(), 0.5);
assertEquals(0.0, tranform.getTranslateY(), 0.5);
}
use of java.awt.geom.AffineTransform in project limelight by slagyr.
the class PropPanelTest method hasChangesWhenTextIsChanged.
@Test
public void hasChangesWhenTextIsChanged() throws Exception {
TextPanel.staticFontRenderingContext = new FontRenderContext(new AffineTransform(), true, true);
Layouts.on(panel, panel.getDefaultLayout());
panel.resetNeededLayout();
panel.setText("blah");
assertEquals(true, panel.needsLayout());
panel.resetNeededLayout();
panel.setText("blah");
assertEquals(false, panel.needsLayout());
panel.setText("new text");
assertEquals(true, panel.needsLayout());
}
use of java.awt.geom.AffineTransform in project scriptographer by scriptographer.
the class TransformStackElement method matrixMultiply.
/**
* Multiplies two 2x3 matrices of double precision values
*/
private double[] matrixMultiply(double[] matrix1, double[] matrix2) {
double[] product = new double[6];
AffineTransform transform1 = new AffineTransform(matrix1);
transform1.concatenate(new AffineTransform(matrix2));
transform1.getMatrix(product);
return product;
}
use of java.awt.geom.AffineTransform in project hid-serial by rayshobby.
the class GAbstractControl method calcTransformedOrigin.
/**
* This method takes a position px, py and calculates the equivalent
* position [ox,oy] as if no transformations have taken place and
* the origin is the top-left corner of the control.
* @param px
* @param py
*/
protected void calcTransformedOrigin(float px, float py) {
AffineTransform aff = new AffineTransform();
aff = getTransform(aff);
temp[0] = px;
temp[1] = py;
try {
aff.inverseTransform(temp, 0, temp, 0, 1);
ox = (float) temp[0] + halfWidth;
oy = (float) temp[1] + halfHeight;
} catch (NoninvertibleTransformException e) {
}
}
use of java.awt.geom.AffineTransform in project hid-serial by rayshobby.
the class GAbstractControl method addControl.
/**
* This will set the rotation of the control to angle overwriting
* any previous rotation set. Then it calculates the centre position
* so that the original top left corner of the control will be the
* position indicated by x,y with respect to the top left corner of
* parent. <br>
*
* The added control will have its position calculated relative to the
* centre of the parent control. <br>
*
* All overloaded methods call this one. <br>
*
* @param c the control to add.
* @param x the leftmost or centre position depending on controlMode
* @param y the topmost or centre position depending on controlMode
* @param angle the rotation angle (replaces any the angle specified in control)
*/
public void addControl(GAbstractControl c, float x, float y, float angle) {
// Ignore if children are not allowed.
if (children == null)
return;
c.rotAngle = angle;
// In child control reset the control so it centred about the origin
AffineTransform aff = new AffineTransform();
aff.setToRotation(angle);
/*
* The following code should result in the x,y and cx,cy coordinates of
* the added control (c) added being measured relative to the centre of
* this control.
*/
switch(G4P.control_mode) {
case CORNER:
case CORNERS:
// Rotate about top corner
c.x = x;
c.y = y;
c.temp[0] = c.halfWidth;
c.temp[1] = c.halfHeight;
aff.transform(c.temp, 0, c.temp, 0, 1);
c.cx = (float) c.temp[0] + x - halfWidth;
c.cy = (float) c.temp[1] + y - halfHeight;
c.x = c.cx - c.halfWidth;
c.y = c.cy - c.halfHeight;
break;
case CENTER:
// Rotate about centre
c.cx = x;
c.cy = y;
c.temp[0] = -c.halfWidth;
c.temp[1] = -c.halfHeight;
aff.transform(c.temp, 0, c.temp, 0, 1);
c.x = c.cx + (float) c.temp[0] - halfWidth;
c.y = c.cy - (float) c.temp[1] - halfHeight;
c.cx -= halfWidth;
c.cy -= halfHeight;
break;
}
c.rotAngle = angle;
// Add to parent
c.parent = this;
c.setZ(z);
// Parent will now be responsible for drawing
c.registeredMethods &= (ALL_METHOD - DRAW_METHOD);
if (children == null)
children = new LinkedList<GAbstractControl>();
children.addLast(c);
Collections.sort(children, new Z_Order());
// Does the control being added have to do anything extra
c.addToParent(this);
}
Aggregations