Java Code Examples for org.jfree.text.TextBlockAnchor#TOP_CENTER

The following examples show how to use org.jfree.text.TextBlockAnchor#TOP_CENTER . 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: CategoricalChartExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public TextBlockAnchor asTextBlockAnchor() {
  switch ( this ) {
    case RIGHT:
      return TextBlockAnchor.CENTER_RIGHT;
    case TOP_RIGHT:
      return TextBlockAnchor.TOP_RIGHT;
    case TOP:
      return TextBlockAnchor.TOP_CENTER;
    case TOP_LEFT:
      return TextBlockAnchor.TOP_LEFT;
    case LEFT:
      return TextBlockAnchor.CENTER_LEFT;
    case BOTTOM_LEFT:
      return TextBlockAnchor.BOTTOM_LEFT;
    case BOTTOM:
      return TextBlockAnchor.BOTTOM_CENTER;
    case BOTTOM_RIGHT:
      return TextBlockAnchor.BOTTOM_RIGHT;
    default:
      return null;
  }
}
 
Example 2
Source File: TextTitle.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: TextTitle.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 4
Source File: TextTitle.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source File: TextTitle.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 6
Source File: TextTitle.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 7
Source File: TextTitle.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 8
Source File: TextTitle.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 9
Source File: TextTitle.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 10
Source File: TextTitle.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 11
Source File: TextTitle.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: TextTitle.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 13
Source File: TextTitle.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 14
Source File: TextTitle.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source File: TextTitle.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 16
Source File: CategoryLabelPositionsTest.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that the equals method distinguishes all fields.
 */
@Test
public void testEquals() {
    CategoryLabelPositions p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    CategoryLabelPositions p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertEquals(p1, p2);

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(p1.equals(p2));
}
 
Example 17
Source File: CategoryLabelPositionsTest.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals method distinguishes all fields.
 */
@Test
public void testEquals() {
    CategoryLabelPositions p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    CategoryLabelPositions p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertEquals(p1, p2);

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(p1.equals(p2));
}
 
Example 18
Source File: CategoryLabelPositionsTest.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Check that the equals method distinguishes all fields.
 */
@Test
public void testEquals() {
    CategoryLabelPositions p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    CategoryLabelPositions p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertEquals(p1, p2);

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(p1.equals(p2));
}
 
Example 19
Source File: CategoryLabelPositionsTest.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals method distinguishes all fields.
 */
@Test
public void testEquals() {
    CategoryLabelPositions p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    CategoryLabelPositions p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertEquals(p1, p2);

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(p1.equals(p2));
}
 
Example 20
Source File: CategoryLabelPositionsTest.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals method distinguishes all fields.
 */
@Test
public void testEquals() {
    CategoryLabelPositions p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    CategoryLabelPositions p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertEquals(p1, p2);

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(p1.equals(p2));
}