本文整理匯總了Java中java.awt.Paint類的典型用法代碼示例。如果您正苦於以下問題:Java Paint類的具體用法?Java Paint怎麽用?Java Paint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Paint類屬於java.awt包,在下文中一共展示了Paint類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawDomainMarker
import java.awt.Paint; //導入依賴的package包/類
/**
* Draws a vertical line on the chart to represent a 'range marker'.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param domainAxis the domain axis.
* @param marker the marker line.
* @param dataArea the axis data area.
*/
public void drawDomainMarker(Graphics2D g2,
ContourPlot plot,
ValueAxis domainAxis,
Marker marker,
Rectangle2D dataArea) {
if (marker instanceof ValueMarker) {
ValueMarker vm = (ValueMarker) marker;
double value = vm.getValue();
Range range = domainAxis.getRange();
if (!range.contains(value)) {
return;
}
double x = domainAxis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM);
Line2D line = new Line2D.Double(x, dataArea.getMinY(), x, dataArea.getMaxY());
Paint paint = marker.getOutlinePaint();
Stroke stroke = marker.getOutlineStroke();
g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
g2.draw(line);
}
}
示例2: drawDomainGridlines
import java.awt.Paint; //導入依賴的package包/類
/**
* Draws the gridlines for the plot, if they are visible.
*
* @param g2 the graphics device.
* @param dataArea the data area.
* @param ticks the ticks.
*/
protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea,
List ticks) {
// no renderer, no gridlines...
if (getRenderer() == null) {
return;
}
// draw the domain grid lines, if any...
if (isDomainGridlinesVisible()) {
Stroke gridStroke = getDomainGridlineStroke();
Paint gridPaint = getDomainGridlinePaint();
if ((gridStroke != null) && (gridPaint != null)) {
Iterator iterator = ticks.iterator();
while (iterator.hasNext()) {
ValueTick tick = (ValueTick) iterator.next();
getRenderer().drawDomainGridLine(g2, this, getDomainAxis(),
dataArea, tick.getValue());
}
}
}
}
示例3: CategoryLineAnnotation
import java.awt.Paint; //導入依賴的package包/類
/**
* Creates a new annotation that draws a line between (category1, value1)
* and (category2, value2).
*
* @param category1 the category (<code>null</code> not permitted).
* @param value1 the value.
* @param category2 the category (<code>null</code> not permitted).
* @param value2 the value.
* @param paint the line color (<code>null</code> not permitted).
* @param stroke the line stroke (<code>null</code> not permitted).
*/
public CategoryLineAnnotation(Comparable category1, double value1,
Comparable category2, double value2,
Paint paint, Stroke stroke) {
if (category1 == null) {
throw new IllegalArgumentException("Null 'category1' argument.");
}
if (category2 == null) {
throw new IllegalArgumentException("Null 'category2' argument.");
}
if (paint == null) {
throw new IllegalArgumentException("Null 'paint' argument.");
}
if (stroke == null) {
throw new IllegalArgumentException("Null 'stroke' argument.");
}
this.category1 = category1;
this.value1 = value1;
this.category2 = category2;
this.value2 = value2;
this.paint = paint;
this.stroke = stroke;
}
示例4: XYPolygonAnnotation
import java.awt.Paint; //導入依賴的package包/類
/**
* Creates a new annotation. The array of polygon coordinates must
* contain an even number of coordinates (each pair is an (x, y) location
* on the plot) and the last point is automatically joined back to the
* first point.
*
* @param polygon the coordinates of the polygon's vertices
* (<code>null</code> not permitted).
* @param stroke the shape stroke (<code>null</code> permitted).
* @param outlinePaint the shape color (<code>null</code> permitted).
* @param fillPaint the paint used to fill the shape (<code>null</code>
* permitted).
*/
public XYPolygonAnnotation(double[] polygon,
Stroke stroke,
Paint outlinePaint, Paint fillPaint) {
if (polygon == null) {
throw new IllegalArgumentException("Null 'polygon' argument.");
}
if (polygon.length % 2 != 0) {
throw new IllegalArgumentException("The 'polygon' array must "
+ "contain an even number of items.");
}
this.polygon = (double[]) polygon.clone();
this.stroke = stroke;
this.outlinePaint = outlinePaint;
this.fillPaint = fillPaint;
}
示例5: drawRangeLine
import java.awt.Paint; //導入依賴的package包/類
/**
* Utility method for drawing a line perpendicular to the range axis (used
* for crosshairs).
*
* @param g2 the graphics device.
* @param dataArea the area defined by the axes.
* @param value the data value.
* @param stroke the line stroke (<code>null</code> not permitted).
* @param paint the line paint (<code>null</code> not permitted).
*/
protected void drawRangeLine(Graphics2D g2, Rectangle2D dataArea,
double value, Stroke stroke, Paint paint) {
double java2D = getRangeAxis().valueToJava2D(value, dataArea,
getRangeAxisEdge());
Line2D line = null;
if (this.orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(java2D, dataArea.getMinY(), java2D,
dataArea.getMaxY());
}
else if (this.orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(dataArea.getMinX(), java2D,
dataArea.getMaxX(), java2D);
}
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(line);
}
示例6: equals
import java.awt.Paint; //導入依賴的package包/類
/**
* Tests this map for equality with an arbitrary object.
*
* @param obj the object (<code>null</code> permitted).
*
* @return A boolean.
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof PaintMap)) {
return false;
}
PaintMap that = (PaintMap) obj;
if (this.store.size() != that.store.size()) {
return false;
}
Set keys = this.store.keySet();
Iterator iterator = keys.iterator();
while (iterator.hasNext()) {
Comparable key = (Comparable) iterator.next();
Paint p1 = getPaint(key);
Paint p2 = that.getPaint(key);
if (!PaintUtilities.equal(p1, p2)) {
return false;
}
}
return true;
}
示例7: drawDomainTickBands
import java.awt.Paint; //導入依賴的package包/類
/**
* Draws the domain tick bands, if any.
*
* @param g2 the graphics device.
* @param dataArea the data area.
* @param ticks the ticks.
*/
public void drawDomainTickBands(Graphics2D g2, Rectangle2D dataArea, List ticks) {
// draw the domain tick bands, if any...
Paint bandPaint = getDomainTickBandPaint();
if (bandPaint != null) {
boolean fillBand = false;
final ValueAxis xAxis = getDomainAxis();
double previous = xAxis.getLowerBound();
Iterator iterator = ticks.iterator();
while (iterator.hasNext()) {
ValueTick tick = (ValueTick) iterator.next();
double current = tick.getValue();
if (fillBand) {
getRenderer().fillDomainGridBand(g2, this, xAxis, dataArea, previous, current);
}
previous = current;
fillBand = !fillBand;
}
double end = xAxis.getUpperBound();
if (fillBand) {
getRenderer().fillDomainGridBand(g2, this, xAxis, dataArea, previous, end);
}
}
}
示例8: transform
import java.awt.Paint; //導入依賴的package包/類
@Override
public Paint transform(VirtualLink input) {
if (vls.contains(input))
return Color.CYAN;
else
return backupVL.get(input.getLayer()).transform(input);
}
示例9: PinteNoArea
import java.awt.Paint; //導入依賴的package包/類
/**
* Pinta a área que não será impressa
*/
private void PinteNoArea(Graphics2D Canvas) {
if (getDiagrama() != null) {
Paint bkp = Canvas.getPaint();
Canvas.setColor(new Color(241, 241, 241));
int x = PaginasW * LarguraPagina;
Canvas.fillRect(x + 2, 2, getWidth() - (x + 4), getHeight() - 4);
int y = PaginasH * AlturaPagina;
Canvas.fillRect(2, y + 2, getWidth() - 4, getHeight() - (y + 4));
Canvas.setPaint(bkp);
}
}
示例10: setCompletePaint
import java.awt.Paint; //導入依賴的package包/類
/**
* Sets the paint used to show the percentage complete and sends a {@link RendererChangeEvent}
* to all registered listeners.
*
* @param paint the paint (<code>null</code> not permitted).
*/
public void setCompletePaint(Paint paint) {
if (paint == null) {
throw new IllegalArgumentException("Null paint not permitted.");
}
this.completePaint = paint;
notifyListeners(new RendererChangeEvent(this));
}
示例11: getBackgroundPaint
import java.awt.Paint; //導入依賴的package包/類
public Paint getBackgroundPaint(double width, double height) {
if (this.isTransparentBackground()) {
return null;
}
if (this.backgroundColor2 == null) {
return this.backgroundColor1;
}
if (this.horizontalBackgroundGradient) {
return new GradientPaint(0, 0, this.backgroundColor1, (float) (width / 2.0), 0, this.backgroundColor2);
} else {
return new GradientPaint(0, 0, this.backgroundColor1, 0, (float) (height / 2.0), this.backgroundColor2);
}
}
示例12: drawRangeTickBands
import java.awt.Paint; //導入依賴的package包/類
/**
* Draws the range tick bands, if any.
*
* @param g2 the graphics device.
* @param dataArea the data area.
* @param ticks the ticks.
*
* @see #setRangeTickBandPaint(Paint)
*/
public void drawRangeTickBands(Graphics2D g2, Rectangle2D dataArea,
List ticks) {
// draw the range tick bands, if any...
Paint bandPaint = getRangeTickBandPaint();
if (bandPaint != null) {
boolean fillBand = false;
ValueAxis axis = getRangeAxis();
double previous = axis.getLowerBound();
Iterator iterator = ticks.iterator();
while (iterator.hasNext()) {
ValueTick tick = (ValueTick) iterator.next();
double current = tick.getValue();
if (fillBand) {
getRenderer().fillRangeGridBand(g2, this, axis, dataArea,
previous, current);
}
previous = current;
fillBand = !fillBand;
}
double end = axis.getUpperBound();
if (fillBand) {
getRenderer().fillRangeGridBand(g2, this, axis, dataArea,
previous, end);
}
}
}
示例13: setSeriesOutlinePaint
import java.awt.Paint; //導入依賴的package包/類
/**
* Sets the series outline paint.
*
* @param series the series index.
* @param p the paint.
*/
public void setSeriesOutlinePaint(int series, Paint p) {
if ((series >= 0) && (series < this.seriesNeedle.length)) {
this.seriesNeedle[series].setOutlinePaint(p);
}
}
示例14: WaterfallBarRenderer
import java.awt.Paint; //導入依賴的package包/類
/**
* Constructs a new waterfall renderer.
*
* @param firstBarPaint the color of the first bar (<code>null</code> not
* permitted).
* @param positiveBarPaint the color for bars with positive values
* (<code>null</code> not permitted).
* @param negativeBarPaint the color for bars with negative values
* (<code>null</code> not permitted).
* @param lastBarPaint the color of the last bar (<code>null</code> not
* permitted).
*/
public WaterfallBarRenderer(Paint firstBarPaint,
Paint positiveBarPaint,
Paint negativeBarPaint,
Paint lastBarPaint) {
super();
if (firstBarPaint == null) {
throw new IllegalArgumentException("Null 'firstBarPaint' argument");
}
if (positiveBarPaint == null) {
throw new IllegalArgumentException(
"Null 'positiveBarPaint' argument"
);
}
if (negativeBarPaint == null) {
throw new IllegalArgumentException(
"Null 'negativeBarPaint' argument"
);
}
if (lastBarPaint == null) {
throw new IllegalArgumentException("Null 'lastBarPaint' argument");
}
this.firstBarPaint = firstBarPaint;
this.lastBarPaint = lastBarPaint;
this.positiveBarPaint = positiveBarPaint;
this.negativeBarPaint = negativeBarPaint;
setGradientPaintTransformer(
new StandardGradientPaintTransformer(
GradientPaintTransformType.CENTER_VERTICAL
)
);
setMinimumBarLength(1.0);
}
示例15: WaterfallBarRenderer
import java.awt.Paint; //導入依賴的package包/類
/**
* Constructs a new waterfall renderer.
*
* @param firstBarPaint the color of the first bar.
* @param positiveBarPaint the color for bars with positive values.
* @param negativeBarPaint the color for bars with negative values.
* @param lastBarPaint the color of the last bar.
*/
public WaterfallBarRenderer(Paint firstBarPaint,
Paint positiveBarPaint,
Paint negativeBarPaint,
Paint lastBarPaint) {
super();
this.firstBarPaint = firstBarPaint;
this.lastBarPaint = lastBarPaint;
this.positiveBarPaint = positiveBarPaint;
this.negativeBarPaint = negativeBarPaint;
setGradientPaintTransformer(
new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
setMinimumBarLength(1.0);
}