org.jfree.text.TextBlock Java Examples

The following examples show how to use org.jfree.text.TextBlock. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CategoryTickTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
@Test
public void testHashCode() {
    Comparable 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);
    assertTrue(t1.equals(t2));
    int h1 = t1.hashCode();
    int h2 = t2.hashCode();
    assertEquals(h1, h2);
}
 
Example #2
Source File: Plot.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont,
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(),
                (float) area.getCenterY(), TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example #3
Source File: Plot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont,
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(),
                (float) area.getCenterY(), TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example #4
Source File: Plot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont,
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(),
                (float) area.getCenterY(), TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example #5
Source File: CategoryTickTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
@Test
public void testHashCode() {
    Comparable 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);
    assertTrue(t1.equals(t2));
    int h1 = t1.hashCode();
    int h2 = t2.hashCode();
    assertEquals(h1, h2);
}
 
Example #6
Source File: CategoryTickTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
@Test
public void testHashCode() {
    Comparable 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);
    assertTrue(t1.equals(t2));
    int h1 = t1.hashCode();
    int h2 = t2.hashCode();
    assertEquals(h1, h2);
}
 
Example #7
Source File: Plot.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont,
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(),
                (float) area.getCenterY(), TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example #8
Source File: CategoryAxis.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block, 
                                          CategoryLabelPosition position, 
                                          Graphics2D g2) {
                                                
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(
        0.0, 0.0, size.getWidth(), size.getHeight()
    );
    Shape rotatedBox = ShapeUtilities.rotateShape(
        box, position.getAngle(), 0.0f, 0.0f
    );
    double h = rotatedBox.getBounds2D().getHeight() 
               + insets.getTop() + insets.getBottom();
    return h;
    
}
 
Example #9
Source File: CategoryAxis.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * A utility method for determining the width of a text block.
 *
 * @param block  the text block.
 * @param position  the position.
 * @param g2  the graphics device.
 *
 * @return The width.
 */
protected double calculateTextBlockWidth(TextBlock block, 
                                         CategoryLabelPosition position, 
                                         Graphics2D g2) {
                                                
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(
        0.0, 0.0, size.getWidth(), size.getHeight()
    );
    Shape rotatedBox = ShapeUtilities.rotateShape(
        box, position.getAngle(), 0.0f, 0.0f
    );
    double w = rotatedBox.getBounds2D().getWidth() 
               + insets.getTop() + insets.getBottom();
    return w;
    
}
 
Example #10
Source File: Plot.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont, 
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(), 
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(), (float) area.getCenterY(), 
                TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example #11
Source File: TextBlockPanel.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Paints the panel.
 *
 * @param g  the graphics device.
 */
public void paintComponent(final Graphics g) {

    super.paintComponent(g);
    final Graphics2D g2 = (Graphics2D) g;

    final Dimension size = getSize();
    final Insets insets = getInsets();
    final Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top,
                                  size.getWidth() - insets.left - insets.right,
                                  size.getHeight() - insets.top - insets.bottom);

    final double x = available.getX();
    final double y = available.getY();
    final float width = (float) available.getWidth();
    final TextBlock block = TextUtilities.createTextBlock(
        this.text, this.font, Color.black, width, new G2TextMeasurer(g2)
    );
    g2.setPaint(Color.black);
    block.draw(g2, (float) x, (float) y, TextBlockAnchor.TOP_LEFT, 0.0f, 0.0f, 0.0);

}
 
Example #12
Source File: CategoryTickTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
@Test
public void testHashCode() {
    Comparable 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);
    assertTrue(t1.equals(t2));
    int h1 = t1.hashCode();
    int h2 = t2.hashCode();
    assertEquals(h1, h2);
}
 
Example #13
Source File: Plot.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont,
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(),
                (float) area.getCenterY(), TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example #14
Source File: Plot.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont,
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(),
                (float) area.getCenterY(), TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
Example #15
Source File: CategoryTickTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
@Test
public void testHashCode() {
    Comparable 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);
    assertTrue(t1.equals(t2));
    int h1 = t1.hashCode();
    int h2 = t2.hashCode();
    assertEquals(h1, h2);
}
 
Example #16
Source File: CategoryAxis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A utility method for determining the width of a text block.
 *
 * @param block  the text block.
 * @param position  the position.
 * @param g2  the graphics device.
 *
 * @return The width.
 */
protected double calculateTextBlockWidth(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft()
            + insets.getRight();
    return w;
}
 
Example #17
Source File: CategoryTickTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    CategoryTick t1 = new CategoryTick("C1", new TextBlock(),
            TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f);
    CategoryTick t2 = (CategoryTick) TestUtilities.serialised(t1);
    assertEquals(t1, t2);
}
 
Example #18
Source File: PiePlot.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Draws the left labels.
 * 
 * @param leftKeys  the keys.
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param linkArea  the link area.
 * @param maxLabelWidth  the maximum label width.
 * @param state  the state.
 */
protected void drawLeftLabels(KeyedValues leftKeys, Graphics2D g2, 
                              Rectangle2D plotArea, Rectangle2D linkArea, 
                              float maxLabelWidth, PiePlotState state) {
    
    PieLabelDistributor distributor1 = new PieLabelDistributor(
        leftKeys.getItemCount()
    );
    double lGap = plotArea.getWidth() * this.labelGap;
    double verticalLinkRadius = state.getLinkArea().getHeight() / 2.0;
    for (int i = 0; i < leftKeys.getItemCount(); i++) {   
        String label = this.labelGenerator.generateSectionLabel(
                this.dataset, leftKeys.getKey(i));
        if (label != null) {
            TextBlock block = TextUtilities.createTextBlock(label, 
                    this.labelFont, this.labelPaint, maxLabelWidth, 
                    new G2TextMeasurer(g2));
            TextBox labelBox = new TextBox(block);
            labelBox.setBackgroundPaint(this.labelBackgroundPaint);
            labelBox.setOutlinePaint(this.labelOutlinePaint);
            labelBox.setOutlineStroke(this.labelOutlineStroke);
            labelBox.setShadowPaint(this.labelShadowPaint);
            double theta = Math.toRadians(
                    leftKeys.getValue(i).doubleValue());
            double baseY = state.getPieCenterY() - Math.sin(theta) 
                           * verticalLinkRadius;
            double hh = labelBox.getHeight(g2);

            distributor1.addPieLabelRecord(new PieLabelRecord(
                    leftKeys.getKey(i), theta, baseY, labelBox, hh,
                    lGap / 2.0 + lGap / 2.0 * -Math.cos(theta), 0.9 
                    + getExplodePercent(this.dataset.getIndex(
                            leftKeys.getKey(i)))));
        }
    }
    distributor1.distributeLabels(plotArea.getMinY(), plotArea.getHeight());
    for (int i = 0; i < distributor1.getItemCount(); i++) {
        drawLeftLabel(g2, state, distributor1.getPieLabelRecord(i));
    }
}
 
Example #19
Source File: CategoryTick.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new tick.
 * 
 * @param category  the category.
 * @param label  the label.
 * @param labelAnchor  the label anchor.
 * @param rotationAnchor  the rotation anchor.
 * @param angle  the rotation angle (in radians).
 */
public CategoryTick(Comparable category,
                    TextBlock label,
                    TextBlockAnchor labelAnchor,
                    TextAnchor rotationAnchor,
                    double angle) {
                        
    super("", TextAnchor.CENTER, rotationAnchor, angle);
    this.category = category;
    this.label = label;
    this.labelAnchor = labelAnchor;
    
}
 
Example #20
Source File: CategoryAxis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A utility method for determining the width of a text block.
 *
 * @param block  the text block.
 * @param position  the position.
 * @param g2  the graphics device.
 *
 * @return The width.
 */
protected double calculateTextBlockWidth(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft()
            + insets.getRight();
    return w;
}
 
Example #21
Source File: CategoryTickTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    CategoryTick t1 = new CategoryTick("C1", new TextBlock(), 
            TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f);
    CategoryTick t2 = (CategoryTick) t1.clone();
    assertTrue(t1 != t2);
    assertTrue(t1.getClass() == t2.getClass());
    assertTrue(t1.equals(t2));
}
 
Example #22
Source File: CategoryAxis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double h = rotatedBox.getBounds2D().getHeight()
               + insets.getTop() + insets.getBottom();
    return h;
}
 
Example #23
Source File: CategoryAxis.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double h = rotatedBox.getBounds2D().getHeight()
               + insets.getTop() + insets.getBottom();
    return h;
}
 
Example #24
Source File: CategoryAxis.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A utility method for determining the width of a text block.
 *
 * @param block  the text block.
 * @param position  the position.
 * @param g2  the graphics device.
 *
 * @return The width.
 */
protected double calculateTextBlockWidth(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft()
            + insets.getRight();
    return w;
}
 
Example #25
Source File: CategoryAxis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double h = rotatedBox.getBounds2D().getHeight()
               + insets.getTop() + insets.getBottom();
    return h;
}
 
Example #26
Source File: CategoryTick.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new tick.
 *
 * @param category  the category.
 * @param label  the label.
 * @param labelAnchor  the label anchor.
 * @param rotationAnchor  the rotation anchor.
 * @param angle  the rotation angle (in radians).
 */
public CategoryTick(Comparable category,
                    TextBlock label,
                    TextBlockAnchor labelAnchor,
                    TextAnchor rotationAnchor,
                    double angle) {

    super("", TextAnchor.CENTER, rotationAnchor, angle);
    this.category = category;
    this.label = label;
    this.labelAnchor = labelAnchor;

}
 
Example #27
Source File: CategoryTickTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    CategoryTick t1 = new CategoryTick("C1", new TextBlock(), 
            TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f);
    CategoryTick t2 = (CategoryTick) t1.clone();
    assertTrue(t1 != t2);
    assertTrue(t1.getClass() == t2.getClass());
    assertTrue(t1.equals(t2));
}
 
Example #28
Source File: CategoryTickTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    CategoryTick t1 = new CategoryTick("C1", new TextBlock(),
            TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f);
    CategoryTick t2 = (CategoryTick) TestUtilities.serialised(t1);
    assertEquals(t1, t2);
}
 
Example #29
Source File: CategoryTick.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new tick.
 *
 * @param category  the category.
 * @param label  the label.
 * @param labelAnchor  the label anchor.
 * @param rotationAnchor  the rotation anchor.
 * @param angle  the rotation angle (in radians).
 */
public CategoryTick(Comparable category,
                    TextBlock label,
                    TextBlockAnchor labelAnchor,
                    TextAnchor rotationAnchor,
                    double angle) {

    super("", TextAnchor.CENTER, rotationAnchor, angle);
    this.category = category;
    this.label = label;
    this.labelAnchor = labelAnchor;

}
 
Example #30
Source File: CategoryTick.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new tick.
 *
 * @param category  the category.
 * @param label  the label.
 * @param labelAnchor  the label anchor.
 * @param rotationAnchor  the rotation anchor.
 * @param angle  the rotation angle (in radians).
 */
public CategoryTick(Comparable category,
                    TextBlock label,
                    TextBlockAnchor labelAnchor,
                    TextAnchor rotationAnchor,
                    double angle) {

    super("", TextAnchor.CENTER, rotationAnchor, angle);
    this.category = category;
    this.label = label;
    this.labelAnchor = labelAnchor;

}