Java 类org.jfree.ui.Spacer 实例源码

项目:parabuild-ci    文件:TextTitle.java   
/**
 * Creates a new title.
 *
 * @param text  the text for the title (<code>null</code> not permitted).
 * @param font  the title font (<code>null</code> not permitted).
 * @param paint  the title paint (<code>null</code> not permitted).
 * @param position  the title position (<code>null</code> not permitted).
 * @param horizontalAlignment  the horizontal alignment (<code>null</code> not permitted).
 * @param verticalAlignment  the vertical alignment (<code>null</code> not permitted).
 * @param spacer  the space to leave around the outside of the title.
 */
public TextTitle(String text, 
                 Font font, 
                 Paint paint, 
                 RectangleEdge position,
                 HorizontalAlignment horizontalAlignment, 
                 VerticalAlignment verticalAlignment,
                 Spacer spacer) {

    super(position, horizontalAlignment, verticalAlignment, spacer);

    if (text == null) {
        throw new NullPointerException("Null 'text' argument.");
    }
    if (font == null) {
        throw new NullPointerException("Null 'font' argument.");
    }
    if (paint == null) {
        throw new NullPointerException("Null 'paint' argument.");
    }
    this.text = text;
    this.font = font;
    this.paint = paint;
    this.backgroundPaint = null;

}
项目:parabuild-ci    文件:ThermometerPlot.java   
/**
 * Creates a new thermometer plot, using default attributes where necessary.
 *
 * @param dataset  the data set.
 */
public ThermometerPlot(ValueDataset dataset) {

  super();

  this.padding = new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.05);
  this.dataset = dataset;
  if (dataset != null) {
    dataset.addChangeListener(this);
  }
  NumberAxis axis = new NumberAxis(null);
  axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
  axis.setAxisLineVisible(false);

  setRangeAxis(axis);
  setAxisRange();
}
项目:parabuild-ci    文件:ImageTitle.java   
/**
 * Creates a new image title with the given image scaled to the given
 * width and height in the given location.
 *
 * @param image  the image (not null).
 * @param height  the height used to draw the image.
 * @param width  the width used to draw the image.
 * @param position  the title position.
 * @param horizontalAlignment  the horizontal alignment.
 * @param verticalAlignment  the vertical alignment.
 * @param spacer  the amount of space to leave around the outside of the title.
 */
public ImageTitle(Image image, int height, int width, RectangleEdge position,
                  HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment,
                  Spacer spacer) {

    super(position, horizontalAlignment, verticalAlignment, spacer);
    if (image == null) {
        throw new NullPointerException("ImageTitle(..): Image argument is null.");
    }
    this.image = image;
    this.height = height;
    this.width = width;

}
项目:parabuild-ci    文件:Title.java   
/**
 * Creates a new title.
 *
 * @param position  the position of the title (<code>null</code> not permitted).
 * @param horizontalAlignment  the horizontal alignment of the title (LEFT, CENTER or RIGHT, 
 *                             <code>null</code> not permitted).
 * @param verticalAlignment  the vertical alignment of the title (TOP, MIDDLE or BOTTOM, 
 *                           <code>null</code> not permitted).
 * @param spacer  the amount of space to leave around the outside of the title 
 *                (<code>null</code> not permitted).
 */
protected Title(RectangleEdge position,
                HorizontalAlignment horizontalAlignment, 
                VerticalAlignment verticalAlignment,
                Spacer spacer) {

    // check arguments...
    if (position == null) {
        throw new IllegalArgumentException("Argument 'position' cannot be null.");
    }
    if (horizontalAlignment == null) {
        throw new IllegalArgumentException("Null 'horizontalAlignment' argument.");
    }

    if (verticalAlignment == null) {
        throw new IllegalArgumentException("Null 'verticalAlignment' argument.");
    }
    if (spacer == null) {
        throw new IllegalArgumentException("Argument 'spacer' cannot be null.");
    }

    // initialise...
    this.position = position;
    this.horizontalAlignment = horizontalAlignment;
    this.verticalAlignment = verticalAlignment;
    this.spacer = spacer;
    this.listenerList = new EventListenerList();
    this.notify = true;

}
项目:parabuild-ci    文件:Title.java   
/**
 * Sets the spacer for the title and sends a {@link TitleChangeEvent} to all registered 
 * listeners.
 *
 * @param spacer  the new spacer (<code>null</code> not permitted).
 */
public void setSpacer(Spacer spacer) {
    if (spacer == null) {
        throw new NullPointerException("AbstractTitle.setSpacer(): null not permitted.");
    }
    if (!this.spacer.equals(spacer)) {
        this.spacer = spacer;
        notifyListeners(new TitleChangeEvent(this));
    }

}
项目:parabuild-ci    文件:TitleTests.java   
/**
 * Problem that the equals(...) method distinguishes all fields.
 */
public void testEquals() {

    // use the TextTitle class because it is a concrete subclass
    Title t1 = new TextTitle();
    Title t2 = new TextTitle();
    assertEquals(t1, t2);

    t1.setPosition(RectangleEdge.LEFT);
    assertFalse(t1.equals(t2));
    t2.setPosition(RectangleEdge.LEFT);
    assertTrue(t1.equals(t2));

    t1.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    assertFalse(t1.equals(t2));
    t2.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    assertTrue(t1.equals(t2));

    t1.setVerticalAlignment(VerticalAlignment.BOTTOM);
    assertFalse(t1.equals(t2));
    t2.setVerticalAlignment(VerticalAlignment.BOTTOM);
    assertTrue(t1.equals(t2));

    t1.setSpacer(new Spacer(Spacer.ABSOLUTE, 5.0, 10.0, 15.0, 20.0));
    assertFalse(t1.equals(t2));
    t2.setSpacer(new Spacer(Spacer.ABSOLUTE, 5.0, 10.0, 15.0, 20.0));
    assertTrue(t1.equals(t2));

}
项目:parabuild-ci    文件:PeriodAxisLabelInfo.java   
/**
 * Creates a new instance.
 * 
 * @param periodClass  the subclass of {@link RegularTimePeriod} to use (<code>null</code> 
 *                     not permitted).
 * @param dateFormat  the date formatter (<code>null</code> not permitted).
 */
public PeriodAxisLabelInfo(Class periodClass, String dateFormat) {
    this(
        periodClass, dateFormat, new Spacer(Spacer.ABSOLUTE, 2, 2, 2, 2), 
        new Font("SansSerif", Font.PLAIN, 10), Color.black, 
        true, new BasicStroke(0.5f), Color.gray
    );
}
项目:parabuild-ci    文件:PeriodAxisLabelInfo.java   
/**
 * Creates a new instance.
 * 
 * @param periodClass  the subclass of {@link RegularTimePeriod} to use (<code>null</code> 
 *                     not permitted).
 * @param dateFormat  the date formatter (<code>null</code> not permitted).
 * @param spacer  controls the space around the band.
 * @param labelFont  the label font.
 * @param labelPaint  the label paint.
 * @param drawDividers  a flag that controls whether dividers are drawn.
 * @param dividerStroke  the stroke used to draw the dividers.
 * @param dividerPaint  the paint used to draw the dividers.
 */
public PeriodAxisLabelInfo(Class periodClass, String dateFormat, 
                           Spacer spacer,
                           Font labelFont, Paint labelPaint, 
                           boolean drawDividers, Stroke dividerStroke, Paint dividerPaint) {
    this.periodClass = periodClass;
    this.dateFormat = new SimpleDateFormat(dateFormat);
    this.spacer = spacer;
    this.labelFont = labelFont;
    this.labelPaint = labelPaint;
    this.drawDividers = drawDividers;
    this.dividerStroke = dividerStroke;
    this.dividerPaint = dividerPaint;
}
项目:parabuild-ci    文件:StandardLegend.java   
/**
 * Sets the outer gap for the legend and sends a {@link LegendChangeEvent} to all
 * registered listeners.
 *
 * @param outerGap  the outer gap (<code>null</code> not permitted).
 */
public void setOuterGap(Spacer outerGap) {
    if (outerGap == null) {
        throw new NullPointerException("Null 'outerGap' argument.");
    }
    this.outerGap = outerGap;
    notifyListeners(new LegendChangeEvent(this));
}
项目:parabuild-ci    文件:StandardLegend.java   
/**
 * Sets the inner gap for the legend and sends a {@link LegendChangeEvent} to all
 * registered listeners.
 *
 * @param innerGap  the inner gap (<code>null</code> not permitted).
 */
public void setInnerGap(Spacer innerGap) {
    if (innerGap == null) {
        throw new NullPointerException("Null 'innerGap' argument.");
    }
    this.innerGap = innerGap;
    notifyListeners(new LegendChangeEvent(this));
}
项目:parabuild-ci    文件:ImageTitle.java   
/**
 * Draws the title on a Java 2D graphics device (such as the screen or a printer).
 *
 * @param g2  the graphics device.
 * @param chartArea  the area within which the title (and plot) should be drawn.
 *
 * @return the area used by the title.
 */
protected Size2D drawHorizontal(Graphics2D g2, Rectangle2D chartArea) {

    double startY = 0.0;
    double topSpace = 0.0;
    double bottomSpace = 0.0;
    double leftSpace = 0.0;
    double rightSpace = 0.0;

    Spacer spacer = getSpacer();
    topSpace = spacer.getTopSpace(this.height);
    bottomSpace = spacer.getBottomSpace(this.height);
    leftSpace = spacer.getLeftSpace(this.width);
    rightSpace = spacer.getRightSpace(this.width);

    if (getPosition() == RectangleEdge.TOP) {
        startY = chartArea.getY() + topSpace;
    }
    else {
        startY = chartArea.getY() + chartArea.getHeight() - bottomSpace - this.height;
    }

    // what is our alignment?
    HorizontalAlignment horizontalAlignment = getHorizontalAlignment();
    double startX = 0.0;
    if (horizontalAlignment == HorizontalAlignment.CENTER) {
        startX = chartArea.getX() + leftSpace + chartArea.getWidth() / 2 - this.width / 2;
    }
    else if (horizontalAlignment == HorizontalAlignment.LEFT) {
        startX = chartArea.getX() + leftSpace;
    }
    else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
        startX = chartArea.getX() + chartArea.getWidth() - rightSpace - this.width;
    }

    g2.drawImage(this.image, (int) startX, (int) startY, this.width, this.height, null);

    return new Size2D(chartArea.getWidth() + leftSpace + rightSpace,
        this.height + topSpace + bottomSpace);

}
项目:parabuild-ci    文件:ImageTitle.java   
/**
 * Draws the title on a Java 2D graphics device (such as the screen or a printer).
 *
 * @param g2  the graphics device.
 * @param chartArea  the area within which the title (and plot) should be drawn.
 *
 * @return the area used by the title.
 */
protected Size2D drawVertical(Graphics2D g2, Rectangle2D chartArea) {

    double startX = 0.0;
    double topSpace = 0.0;
    double bottomSpace = 0.0;
    double leftSpace = 0.0;
    double rightSpace = 0.0;

    Spacer spacer = getSpacer();
    if (spacer != null) {
        topSpace = spacer.getTopSpace(this.height);
        bottomSpace = spacer.getBottomSpace(this.height);
        leftSpace = spacer.getLeftSpace(this.width);
        rightSpace = spacer.getRightSpace(this.width);
    }

    if (getPosition() == RectangleEdge.LEFT) {
        startX = chartArea.getX() + leftSpace;
    }
    else {
        startX = chartArea.getMaxX() - rightSpace - this.width;
    }

    // what is our alignment?
    VerticalAlignment alignment = getVerticalAlignment();
    double startY = 0.0;
    if (alignment == VerticalAlignment.CENTER) {
        startY = chartArea.getMinY() + topSpace + chartArea.getHeight() / 2 - this.height / 2;
    }
    else if (alignment == VerticalAlignment.TOP) {
        startY = chartArea.getMinY() + topSpace;
    }
    else if (alignment == VerticalAlignment.BOTTOM) {
        startY = chartArea.getMaxY() - bottomSpace - this.height;
    }

    g2.drawImage(this.image, (int) startX, (int) startY, this.width, this.height, null);

    return new Size2D(chartArea.getWidth() + leftSpace + rightSpace,
        this.height + topSpace + bottomSpace);

}
项目:parabuild-ci    文件:ImageTitle.java   
/**
 * Returns the preferred width of the title.
 *
 * @param g2  the graphics device.
 * @param height  the height (ignored).
 *
 * @return the preferred width of the title.
 */
public float getPreferredWidth(Graphics2D g2, float height) {
    Spacer spacer = getSpacer();
    float result = (float) spacer.getAdjustedWidth(this.width);
    return result;

}
项目:parabuild-ci    文件:DateTitle.java   
/**
 * Creates a new chart title that displays the current date.
 * <p>
 * The date style should be one of:  <code>SHORT</code>, <code>MEDIUM</code>,
 * <code>LONG</code> or <code>FULL</code> (defined in <code>java.util.DateFormat<code>).
 * <P>
 * For the locale, you can use <code>Locale.getDefault()</code> for the default locale.
 *
 * @param style  the date style.
 * @param locale  the locale.
 * @param font  the font (not null).
 * @param paint  the text color (not null).
 * @param position  the relative location of this title (use constants in Title).
 * @param horizontalAlignment  the horizontal text alignment of this title (use constants
 *                             in Title).
 * @param verticalAlignment  the vertical text alignment of this title (use constants in
 *                           Title).
 * @param spacer  determines the blank space around the outside of the title (not null).
 */
public DateTitle(int style, Locale locale, Font font, Paint paint,
                 RectangleEdge position, 
                 HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment,
                 Spacer spacer) {

    super(DateFormat.getDateInstance(style, locale).format(new Date()),
          font, paint,
          position, horizontalAlignment, verticalAlignment,
          spacer);

}
项目:parabuild-ci    文件:ImageTitle.java   
/**
 * Returns the preferred height of the title.
 *
 * @param g2  the graphics device.
 * @param width  the width (ignored).
 *
 * @return the preferred height of the title.
 */
public float getPreferredHeight(Graphics2D g2, float width) {
    Spacer spacer = getSpacer();
    float result = (float) spacer.getAdjustedHeight(this.height);
    return result;
}
项目:parabuild-ci    文件:Title.java   
/**
 * Returns the spacer  which determines the blank space around the edges of the title.
 *
 * @return The spacer (never <code>null</code>).
 */
public Spacer getSpacer() {
    return this.spacer;
}
项目:parabuild-ci    文件:XYPlot.java   
/**
 * Returns the axis offset.
 *
 * @return The axis offset.
 */
public Spacer getAxisOffset() {
    return this.axisOffset;
}
项目:parabuild-ci    文件:XYPlot.java   
/**
 * Sets the axis offsets (gap between the data area and the axes).
 *
 * @param offset  the offset.
 */
public void setAxisOffset(Spacer offset) {
    this.axisOffset = offset;
    notifyListeners(new PlotChangeEvent(this));
}
项目:parabuild-ci    文件:ThermometerPlot.java   
/**
 * Returns the padding for the thermometer.  This is the space inside the plot area.
 *
 * @return the padding.
 */
public Spacer getPadding() {
  return this.padding;
}
项目:parabuild-ci    文件:ThermometerPlot.java   
/**
 * Sets the padding for the thermometer.
 *
 * @param padding  the padding.
 */
public void setPadding(Spacer padding) {
  this.padding = padding;
  notifyListeners(new PlotChangeEvent(this));
}
项目:parabuild-ci    文件:CategoryPlot.java   
/**
 * Returns the axis offset.
 *
 * @return the axis offset.
 */
public Spacer getAxisOffset() {
    return this.axisOffset;
}
项目:parabuild-ci    文件:CategoryPlot.java   
/**
 * Sets the axis offsets (gap between the data area and the axes).
 *
 * @param offset  the offset.
 */
public void setAxisOffset(Spacer offset) {
    this.axisOffset = offset;
    notifyListeners(new PlotChangeEvent(this));
}
项目:parabuild-ci    文件:PeriodAxisLabelInfo.java   
/**
 * Returns the spacer for the band.
 * 
 * @return The spacer.
 */
public Spacer getSpacer() {
    return this.spacer;   
}
项目:parabuild-ci    文件:StandardLegend.java   
/**
 * Returns the outer gap for the legend.  This is the amount of blank space around the outside 
 * of the legend.
 *
 * @return The gap (never <code>null</code>).
 */
public Spacer getOuterGap() {
    return this.outerGap;
}
项目:parabuild-ci    文件:StandardLegend.java   
/**
 * Returns the inner gap for the legend.  This is the amount of blank space around the inside
 * of the legend.
 *
 * @return The gap (never <code>null</code>).
 */
public Spacer getInnerGap() {
    return this.innerGap;
}