use of org.jfree.chart.text.TextBlockAnchor in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class TextTitle method drawVertical.
/**
* Draws a the title vertically within the specified area. This method
* will be called from the {@link #draw(Graphics2D, Rectangle2D) draw}
* method.
*
* @param g2 the graphics device.
* @param area the area for the title.
*/
protected void drawVertical(Graphics2D g2, Rectangle2D area) {
Rectangle2D titleArea = (Rectangle2D) area.clone();
g2.setFont(this.font);
g2.setPaint(this.paint);
TextBlockAnchor anchor = null;
float y = 0.0f;
VerticalAlignment verticalAlignment = getVerticalAlignment();
if (verticalAlignment == VerticalAlignment.TOP) {
y = (float) titleArea.getY();
anchor = TextBlockAnchor.TOP_RIGHT;
} else if (verticalAlignment == VerticalAlignment.BOTTOM) {
y = (float) titleArea.getMaxY();
anchor = TextBlockAnchor.TOP_LEFT;
} else if (verticalAlignment == VerticalAlignment.CENTER) {
y = (float) titleArea.getCenterY();
anchor = TextBlockAnchor.TOP_CENTER;
}
float x = 0.0f;
RectangleEdge position = getPosition();
if (position == RectangleEdge.LEFT) {
x = (float) titleArea.getX();
} else if (position == RectangleEdge.RIGHT) {
x = (float) titleArea.getMaxX();
if (verticalAlignment == VerticalAlignment.TOP) {
anchor = TextBlockAnchor.BOTTOM_RIGHT;
} else if (verticalAlignment == VerticalAlignment.CENTER) {
anchor = TextBlockAnchor.BOTTOM_CENTER;
} else if (verticalAlignment == VerticalAlignment.BOTTOM) {
anchor = TextBlockAnchor.BOTTOM_LEFT;
}
}
this.content.draw(g2, x, y, anchor, x, y, -Math.PI / 2.0);
}
use of org.jfree.chart.text.TextBlockAnchor in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class CategoryTickTest method testHashCode.
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashCode() {
Comparable<String> c1 = "C1";
TextBlock tb1 = new TextBlock();
tb1.addLine(new TextLine("Block 1"));
tb1.addLine(new TextLine("Block 2"));
TextBlockAnchor tba1 = TextBlockAnchor.CENTER;
TextAnchor ta1 = TextAnchor.CENTER;
CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
assertEquals(t1, t2);
int h1 = t1.hashCode();
int h2 = t2.hashCode();
assertEquals(h1, h2);
}
use of org.jfree.chart.text.TextBlockAnchor in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class TextTitle method drawHorizontal.
/**
* Draws a the title horizontally within the specified area. This method
* will be called from the {@link #draw(Graphics2D, Rectangle2D) draw}
* method.
*
* @param g2 the graphics device.
* @param area the area for the title.
*/
protected void drawHorizontal(Graphics2D g2, Rectangle2D area) {
Rectangle2D titleArea = (Rectangle2D) area.clone();
g2.setFont(this.font);
g2.setPaint(this.paint);
TextBlockAnchor anchor = null;
float x = 0.0f;
HorizontalAlignment horizontalAlignment = getHorizontalAlignment();
if (horizontalAlignment == HorizontalAlignment.LEFT) {
x = (float) titleArea.getX();
anchor = TextBlockAnchor.TOP_LEFT;
} else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
x = (float) titleArea.getMaxX();
anchor = TextBlockAnchor.TOP_RIGHT;
} else if (horizontalAlignment == HorizontalAlignment.CENTER) {
x = (float) titleArea.getCenterX();
anchor = TextBlockAnchor.TOP_CENTER;
}
float y = 0.0f;
RectangleEdge position = getPosition();
if (position == RectangleEdge.TOP) {
y = (float) titleArea.getY();
} else if (position == RectangleEdge.BOTTOM) {
y = (float) titleArea.getMaxY();
if (horizontalAlignment == HorizontalAlignment.LEFT) {
anchor = TextBlockAnchor.BOTTOM_LEFT;
} else if (horizontalAlignment == HorizontalAlignment.CENTER) {
anchor = TextBlockAnchor.BOTTOM_CENTER;
} else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
anchor = TextBlockAnchor.BOTTOM_RIGHT;
}
}
this.content.draw(g2, x, y, anchor);
}
use of org.jfree.chart.text.TextBlockAnchor in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class CategoryTickTest method testEquals.
/**
* Confirm that the equals method can distinguish all the required fields.
*/
@Test
public void testEquals() {
Comparable<String> c1 = "C1";
Comparable<String> c2 = "C2";
TextBlock tb1 = new TextBlock();
tb1.addLine(new TextLine("Block 1"));
TextBlock tb2 = new TextBlock();
tb1.addLine(new TextLine("Block 2"));
TextBlockAnchor tba1 = TextBlockAnchor.CENTER;
TextBlockAnchor tba2 = TextBlockAnchor.BOTTOM_CENTER;
TextAnchor ta1 = TextAnchor.CENTER;
TextAnchor ta2 = TextAnchor.BASELINE_LEFT;
CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
assertEquals(t1, t2);
t1 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
assertNotEquals(t1, t2);
t2 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
assertEquals(t1, t2);
t1 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
assertNotEquals(t1, t2);
t2 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
assertEquals(t1, t2);
t1 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
assertNotEquals(t1, t2);
t2 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
assertEquals(t1, t2);
t1 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
assertNotEquals(t1, t2);
t2 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
assertEquals(t1, t2);
t1 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
assertNotEquals(t1, t2);
t2 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
assertEquals(t1, t2);
}
Aggregations