本文整理汇总了Java中java.awt.geom.Line2D.Float方法的典型用法代码示例。如果您正苦于以下问题:Java Line2D.Float方法的具体用法?Java Line2D.Float怎么用?Java Line2D.Float使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.Line2D
的用法示例。
在下文中一共展示了Line2D.Float方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUnderlineShape
import java.awt.geom.Line2D; //导入方法依赖的package包/类
Shape getUnderlineShape(float thickness,
float x1,
float x2,
float y) {
GeneralPath gp = new GeneralPath();
Line2D.Float line = new Line2D.Float(x1, y, x2, y);
gp.append(stroke.createStrokedShape(line), false);
line.y1 += DEFAULT_THICKNESS;
line.y2 += DEFAULT_THICKNESS;
line.x1 += DEFAULT_THICKNESS;
gp.append(stroke.createStrokedShape(line), false);
return gp;
}
示例2: paint
import java.awt.geom.Line2D; //导入方法依赖的package包/类
/**
* Method used to draw the GUI, primarily with the separator lines
*/
public void paint(Graphics g) {
Dimension d = contentPane.getSize();
super.paint(g); // fixes the immediate problem.
Graphics2D g2 = (Graphics2D) g;
g2.setColor(new Color(50, 50, 50));
horizontalLine1 = new Line2D.Float(45, d.height-290, d.width - 45, d.height-290);
verticalLine1 = new Line2D.Float(d.width/3 - 10, 100 , d.width/3 - 10, d.height - 325);
verticalLine2 = new Line2D.Float((2*d.width)/3-10, 100 , (2*d.width)/3-10, d.height - 325);
verticalLine3 = new Line2D.Float(d.width/3 - 10, 390 , d.width/3 - 10, d.height - 25);
verticalLine4 = new Line2D.Float((2*d.width)/3-10, 390 , (2*d.width)/3-10, d.height - 25);
//g2.setColor(Color.DARK_GRAY);
g2.draw(horizontalLine1);
g2.draw(verticalLine1);
g2.draw(verticalLine2);
g2.draw(verticalLine3);
g2.draw(verticalLine4);
}
示例3: drawVerticalAxisTrace
import java.awt.geom.Line2D; //导入方法依赖的package包/类
/**
* Draws a horizontal line used to trace the mouse position to the vertical axis.
*
* @param g2
* the graphics device.
* @param y
* the y-coordinate of the trace line.
*/
private void drawVerticalAxisTrace(Graphics2D g2, int y) {
Rectangle2D dataArea = getScreenDataArea();
g2.setXORMode(Color.orange);
if ((int) dataArea.getMinY() < y && y < (int) dataArea.getMaxY()) {
if (this.horizontalTraceLine != null) {
g2.draw(this.horizontalTraceLine);
this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y);
} else {
this.horizontalTraceLine = new Line2D.Float((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y);
}
g2.draw(this.horizontalTraceLine);
}
// Reset to the default 'overwrite' mode
g2.setPaintMode();
}
示例4: drawUnderline
import java.awt.geom.Line2D; //导入方法依赖的package包/类
void drawUnderline(Graphics2D g2d,
float thickness,
float x1,
float x2,
float y) {
Stroke saveStroke = g2d.getStroke();
g2d.setStroke(stroke);
Line2D.Float drawLine = new Line2D.Float(x1, y, x2, y);
g2d.draw(drawLine);
drawLine.y1 += DEFAULT_THICKNESS;
drawLine.y2 += DEFAULT_THICKNESS;
drawLine.x1 += DEFAULT_THICKNESS;
g2d.draw(drawLine);
g2d.setStroke(saveStroke);
}
示例5: drawVerticalAxisTrace
import java.awt.geom.Line2D; //导入方法依赖的package包/类
/**
* Draws a horizontal line used to trace the mouse position to the vertical axis.
*
* @param y the y-coordinate of the trace line.
*/
private void drawVerticalAxisTrace(int y) {
Graphics2D g2 = (Graphics2D) getGraphics();
Rectangle2D dataArea = getScaledDataArea();
g2.setXORMode(java.awt.Color.orange);
if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) {
if (this.horizontalTraceLine != null) {
g2.draw(this.horizontalTraceLine);
this.horizontalTraceLine.setLine(
(int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y
);
}
else {
this.horizontalTraceLine = new Line2D.Float(
(int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y
);
}
g2.draw(this.horizontalTraceLine);
}
}
示例6: drawHorizontalAxisTrace
import java.awt.geom.Line2D; //导入方法依赖的package包/类
/**
* Draws a vertical line used to trace the mouse position to the horizontal
* axis.
*
* @param g2 the graphics device.
* @param x the x-coordinate of the trace line.
*/
private void drawHorizontalAxisTrace(Graphics2D g2, int x) {
Rectangle2D dataArea = getScreenDataArea();
g2.setXORMode(Color.orange);
if (((int) dataArea.getMinX() < x) && (x < (int) dataArea.getMaxX())) {
if (this.verticalTraceLine != null) {
g2.draw(this.verticalTraceLine);
this.verticalTraceLine.setLine(x, (int) dataArea.getMinY(), x,
(int) dataArea.getMaxY());
}
else {
this.verticalTraceLine = new Line2D.Float(x,
(int) dataArea.getMinY(), x, (int) dataArea.getMaxY());
}
g2.draw(this.verticalTraceLine);
}
// Reset to the default 'overwrite' mode
g2.setPaintMode();
}
示例7: drawVerticalAxisTrace
import java.awt.geom.Line2D; //导入方法依赖的package包/类
/**
* Draws a horizontal line used to trace the mouse position to the vertical
* axis.
*
* @param g2 the graphics device.
* @param y the y-coordinate of the trace line.
*/
private void drawVerticalAxisTrace(Graphics2D g2, int y) {
Rectangle2D dataArea = getScreenDataArea();
g2.setXORMode(Color.orange);
if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) {
if (this.horizontalTraceLine != null) {
g2.draw(this.horizontalTraceLine);
this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y,
(int) dataArea.getMaxX(), y);
}
else {
this.horizontalTraceLine = new Line2D.Float(
(int) dataArea.getMinX(), y, (int) dataArea.getMaxX(),
y);
}
g2.draw(this.horizontalTraceLine);
}
// Reset to the default 'overwrite' mode
g2.setPaintMode();
}
示例8: paint
import java.awt.geom.Line2D; //导入方法依赖的package包/类
public void paint(Graphics g) {
Dimension d = this.getSize();
super.paint(g); // fixes the immediate problem.
Graphics2D g2 = (Graphics2D) g;
horizontalLine1 = new Line2D.Float(45, d.height-290, d.width - 45, d.height-290);
verticalLine1 = new Line2D.Float(d.width/3+10, 100 , d.width/3+10, d.height - 325);
verticalLine2 = new Line2D.Float((2*d.width)/3-10, 100 , (2*d.width)/3-10, d.height - 325);
verticalLine3 = new Line2D.Float(d.width/3+10, 350 , d.width/3+10, d.height - 50);
verticalLine4 = new Line2D.Float((2*d.width)/3-10, 350 , (2*d.width)/3-10, d.height - 50);
//System.out.println("Height: "+d.height+"\tWidth: "+d.width);
// (45, 267, 129, 20)
//g2.setColor(Color.DARK_GRAY);
g2.draw(horizontalLine1);
g2.draw(verticalLine1);
g2.draw(verticalLine2);
g2.draw(verticalLine3);
g2.draw(verticalLine4);
}
示例9: createFlankedShapeLegendItem
import java.awt.geom.Line2D; //导入方法依赖的package包/类
private LegendItem createFlankedShapeLegendItem(String label, double minValue, double maxValue, Shape itemShape,
Paint shapeFillPaint, boolean shapeOutlineVisible, DateFormat dateFormat) {
// configure legend item
String description = "";
String toolTipText = "";
String urlText = "";
boolean shapeVisible = true;
boolean shapeFilled = true;
Paint outlinePaint = Color.BLACK;
Stroke outlineStroke = DEFAULT_OUTLINE_STROKE;
boolean lineVisible = false;
Shape line = new Line2D.Float();
Stroke lineStroke = new BasicStroke(); // basic stroke is fine here, since continuous legend
// item does not show a line
Paint linePaint = Color.BLACK;
// create legend item
FlankedShapeLegendItem legendItem = new FlankedShapeLegendItem(label, description, toolTipText, urlText,
shapeVisible, itemShape, shapeFilled, shapeFillPaint, shapeOutlineVisible, outlinePaint, outlineStroke,
lineVisible, line, lineStroke, linePaint);
if (dateFormat != null) {
legendItem.setLeftShapeLabel(dateFormat.format(new Date((long) minValue)));
legendItem.setRightShapeLabel(dateFormat.format(new Date((long) maxValue)));
} else {
// set intelligently rounded strings as labels
int powerOf10 = DataStructureUtils.getOptimalPrecision(minValue, maxValue);
legendItem.setLeftShapeLabel(DataStructureUtils.getRoundedString(minValue, powerOf10 - 1));
legendItem.setRightShapeLabel(DataStructureUtils.getRoundedString(maxValue, powerOf10 - 1));
}
return legendItem;
}
示例10: getShape
import java.awt.geom.Line2D; //导入方法依赖的package包/类
@Override
Shape getShape() {
if (getAnchorCount() > 0) {
GeneralPath relationLine = new GeneralPath();
relationLine.moveTo(getStartX(), getStartY());
for (RelationAnchor anchor : getAnchors()) {
relationLine.lineTo(anchor.getX(), anchor.getY());
}
relationLine.lineTo(getEndX(), getEndY());
return relationLine;
} else {
return new Line2D.Float(getStartX(), getStartY(), getEndX(), getEndY());
}
}
示例11: Snakelet
import java.awt.geom.Line2D; //导入方法依赖的package包/类
public Snakelet(int index, int point1, int point2, int ts){
idx = index;
i1 = point1;
i2 = point2;
line = new Line2D.Float();
on = false;
type = -1;
timestamp = ts;
}
示例12: paint
import java.awt.geom.Line2D; //导入方法依赖的package包/类
/**
*
*/
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
Stroke stroke = g2.getStroke();
g2.setStroke(getSelectionStroke());
g.setColor(getSelectionColor());
Point last = state.getAbsolutePoint(0).getPoint();
for (int i = 1; i < state.getAbsolutePointCount(); i++)
{
Point current = state.getAbsolutePoint(i).getPoint();
Line2D line = new Line2D.Float(last.x, last.y, current.x, current.y);
Rectangle bounds = g2.getStroke().createStrokedShape(line)
.getBounds();
if (g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height))
{
g2.draw(line);
}
last = current;
}
g2.setStroke(stroke);
super.paint(g);
}
示例13: draw
import java.awt.geom.Line2D; //导入方法依赖的package包/类
/**
* Draws the annotation. This method is called by the {@link XYPlot} class, you
* won't normally need to call it yourself.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the data area.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
*/
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
ValueAxis domainAxis, ValueAxis rangeAxis) {
PlotOrientation orientation = plot.getOrientation();
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
plot.getDomainAxisLocation(), orientation
);
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
plot.getRangeAxisLocation(), orientation
);
float j2DX1 = 0.0f;
float j2DX2 = 0.0f;
float j2DY1 = 0.0f;
float j2DY2 = 0.0f;
if (orientation == PlotOrientation.VERTICAL) {
j2DX1 = (float) domainAxis.valueToJava2D(this.x1, dataArea, domainEdge);
j2DY1 = (float) rangeAxis.valueToJava2D(this.y1, dataArea, rangeEdge);
j2DX2 = (float) domainAxis.valueToJava2D(this.x2, dataArea, domainEdge);
j2DY2 = (float) rangeAxis.valueToJava2D(this.y2, dataArea, rangeEdge);
}
else if (orientation == PlotOrientation.HORIZONTAL) {
j2DY1 = (float) domainAxis.valueToJava2D(this.x1, dataArea, domainEdge);
j2DX1 = (float) rangeAxis.valueToJava2D(this.y1, dataArea, rangeEdge);
j2DY2 = (float) domainAxis.valueToJava2D(this.x2, dataArea, domainEdge);
j2DX2 = (float) rangeAxis.valueToJava2D(this.y2, dataArea, rangeEdge);
}
g2.setPaint(this.paint);
g2.setStroke(this.stroke);
Line2D line = new Line2D.Float(j2DX1, j2DY1, j2DX2, j2DY2);
g2.draw(line);
}
示例14: getLegendItem
import java.awt.geom.Line2D; //导入方法依赖的package包/类
/**
* Returns a legend item for a series.
*
* @param datasetIndex the dataset index (zero-based).
* @param series the series index (zero-based).
*
* @return The legend item.
*/
public LegendItem getLegendItem(int datasetIndex, int series) {
CategoryPlot cp = getPlot();
if (cp == null) {
return null;
}
CategoryDataset dataset;
dataset = cp.getDataset(datasetIndex);
String label = getLegendItemLabelGenerator().generateLabel(dataset,
series);
String description = label;
String toolTipText = null;
if (getLegendItemToolTipGenerator() != null) {
toolTipText = getLegendItemToolTipGenerator().generateLabel(
dataset, series);
}
String urlText = null;
if (getLegendItemURLGenerator() != null) {
urlText = getLegendItemURLGenerator().generateLabel(dataset,
series);
}
Shape shape = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0);
Paint paint = getSeriesPaint(series);
Paint outlinePaint = getSeriesOutlinePaint(series);
Stroke outlineStroke = getSeriesOutlineStroke(series);
LegendItem result = new LegendItem(label, description, toolTipText,
urlText, true, shape, true, paint, isDrawBarOutline(),
outlinePaint, outlineStroke, false, new Line2D.Float(),
new BasicStroke(1.0f), Color.black);
if (this.gradientPaintTransformer != null) {
result.setFillPaintTransformer(this.gradientPaintTransformer);
}
return result;
}
示例15: getVerticalRulings
import java.awt.geom.Line2D; //导入方法依赖的package包/类
private List<Ruling> getVerticalRulings(BufferedImage image) {
// get all vertical edges, which we'll define as a change in grayscale colour
// along a straight line of a certain length
ArrayList<Ruling> verticalRulings = new ArrayList<>();
Raster r = image.getRaster();
int width = r.getWidth();
int height = r.getHeight();
for (int y = 0; y < height; y++) {
int[] lastPixel = r.getPixel(0, y, (int[]) null);
for (int x = 1; x < width - 1; x++) {
int[] currPixel = r.getPixel(x, y, (int[]) null);
int diff = Math.abs(currPixel[0] - lastPixel[0]);
if (diff > GRAYSCALE_INTENSITY_THRESHOLD) {
// we hit what could be a line
// don't bother scanning it if we've hit a pixel in the line before
boolean alreadyChecked = false;
for (Line2D.Float line : verticalRulings) {
if (x == line.getX1() && y >= line.getY1() && y <= line.getY2()) {
alreadyChecked = true;
break;
}
}
if (alreadyChecked) {
lastPixel = currPixel;
continue;
}
int lineY = y + 1;
while (lineY < height) {
int[] linePixel = r.getPixel(x, lineY, (int[]) null);
int[] leftPixel = r.getPixel(x - 1, lineY, (int[]) null);
if (Math.abs(linePixel[0] - leftPixel[0]) <= GRAYSCALE_INTENSITY_THRESHOLD
|| Math.abs(currPixel[0] - linePixel[0]) > GRAYSCALE_INTENSITY_THRESHOLD) {
break;
}
lineY++;
}
int endY = lineY - 1;
int lineLength = endY - y;
if (lineLength > VERTICAL_EDGE_HEIGHT_MINIMUM) {
verticalRulings.add(new Ruling(new Point2D.Float(x, y), new Point2D.Float(x, endY)));
}
}
lastPixel = currPixel;
}
}
return verticalRulings;
}