當前位置: 首頁>>代碼示例>>Java>>正文


Java Line2D.Double方法代碼示例

本文整理匯總了Java中java.awt.geom.Line2D.Double方法的典型用法代碼示例。如果您正苦於以下問題:Java Line2D.Double方法的具體用法?Java Line2D.Double怎麽用?Java Line2D.Double使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.geom.Line2D的用法示例。


在下文中一共展示了Line2D.Double方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawVerticalLine

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * Utility method for drawing a vertical line on the data area of the plot.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param value  the coordinate, where to draw the line.
 * @param stroke  the stroke to use.
 * @param paint  the paint to use.
 */
protected void drawVerticalLine(Graphics2D g2, Rectangle2D dataArea,
                                double value, Stroke stroke, Paint paint) {

    ValueAxis axis = getDomainAxis();
    if (getOrientation() == PlotOrientation.HORIZONTAL) {
        axis = getRangeAxis();
    }
    if (axis.getRange().contains(value)) {
        double xx = axis.valueToJava2D(value, dataArea, 
                RectangleEdge.BOTTOM);
        Line2D line = new Line2D.Double(xx, dataArea.getMinY(), xx, 
                dataArea.getMaxY());
        g2.setStroke(stroke);
        g2.setPaint(paint);
        g2.draw(line);
    }

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:XYPlot.java

示例2: drawRangeLine

import java.awt.geom.Line2D; //導入方法依賴的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.
 * @param paint  the line paint.
 */
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);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:27,代碼來源:CategoryPlot.java

示例3: addRemoveControlPoint

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * Adds or removes a control point on a specified location
 * @param localLocation the local location
 */
public void addRemoveControlPoint (Point localLocation) {
    ArrayList<Point> list = new ArrayList<Point> (getControlPoints());
        if(!removeControlPoint(localLocation,list,deleteSensitivity)){
            Point exPoint=null;int index=0;
            for (Point elem : list) {
                if(exPoint!=null){
                    Line2D l2d=new Line2D.Double(exPoint,elem);
                    if(l2d.ptLineDist(localLocation)<createSensitivity){
                        list.add(index,localLocation);
                        break;
                    }
                }
                exPoint=elem;index++;
            }
        }
        setControlPoints(list,false);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:FreeConnectionWidget.java

示例4: paint

import java.awt.geom.Line2D; //導入方法依賴的package包/類
@Override
public void paint(Graphics2D g, Bounds aBounds, Diagram diagram) {
    QBounds bounds = (QBounds) aBounds;
    label.setLocation(0, 0);
    Dimension size = new Dimension((int) bounds.getSize().getWidth() - 4,
            (int) bounds.getSize().getHeight());
    label.setPreferredSize(size);
    label.setSize(label.getPreferredSize());
    g.setColor(Color.black);
    Line2D line = new Line2D.Double(8, getMinHeight(), getMinWidth() - 16,
            getMinHeight());
    Stroke stroke = g.getStroke();
    g.setStroke(this.stroke);
    g.draw(line);
    g.setStroke(stroke);
    paintText(g);
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:18,代碼來源:Label.java

示例5: drawHorizontalLine

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * Utility method for drawing a horizontal line across the data area of the plot.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param value  the coordinate, where to draw the line.
 * @param stroke  the stroke to use.
 * @param paint  the paint to use.
 */
protected void drawHorizontalLine(Graphics2D g2, Rectangle2D dataArea,
                                  double value, Stroke stroke, Paint paint) {

    ValueAxis axis = getRangeAxis();  
    if (getOrientation() == PlotOrientation.HORIZONTAL) {
        axis = getDomainAxis();   
    }
    if (axis.getRange().contains(value)) {
        double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT);
        Line2D line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy);
        g2.setStroke(stroke);
        g2.setPaint(paint);
        g2.draw(line);
    }

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:XYPlot.java

示例6: XYLineAndShapeRenderer

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * Creates a new renderer.
 * 
 * @param lines  lines visible?
 * @param shapes  shapes visible?
 */
public XYLineAndShapeRenderer(boolean lines, boolean shapes) {
    this.linesVisible = null;
    this.seriesLinesVisible = new BooleanList();
    this.baseLinesVisible = lines;
    this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0);
    
    this.shapesVisible = null;
    this.seriesShapesVisible = new BooleanList();
    this.baseShapesVisible = shapes;
    
    this.shapesFilled = null;
    this.useFillPaint = false;     // use item paint for fills by default
    this.seriesShapesFilled = new BooleanList();
    this.baseShapesFilled = true;

    this.drawOutlines = true;     
    this.useOutlinePaint = false;  // use item paint for outlines by 
                                   // default, not outline paint
    
    this.drawSeriesLineAsPath = false;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:XYLineAndShapeRenderer.java

示例7: drawRangeCrosshair

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * Draws a range crosshair.
 * 
 * @param g2  the graphics target.
 * @param dataArea  the data area.
 * @param orientation  the plot orientation.
 * @param value  the crosshair value.
 * @param axis  the axis against which the value is measured.
 * @param stroke  the stroke used to draw the crosshair line.
 * @param paint  the paint used to draw the crosshair line.
 * 
 * @since 1.0.4
 */
protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, 
        PlotOrientation orientation, double value, ValueAxis axis, 
        Stroke stroke, Paint paint) {
    
    if (axis.getRange().contains(value)) {
        Line2D line = null;
        if (orientation == PlotOrientation.HORIZONTAL) {
            double xx = axis.valueToJava2D(value, dataArea, 
                    RectangleEdge.BOTTOM);
            line = new Line2D.Double(xx, dataArea.getMinY(), xx, 
                    dataArea.getMaxY());
        }
        else {
            double yy = axis.valueToJava2D(value, dataArea, 
                    RectangleEdge.LEFT);
            line = new Line2D.Double(dataArea.getMinX(), yy, 
                    dataArea.getMaxX(), yy);
        }
        g2.setStroke(stroke);
        g2.setPaint(paint);
        g2.draw(line);
    }
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:38,代碼來源:XYPlot.java

示例8: StackedXYAreaRendererState

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * Creates a new state for the renderer.
 * 
 * @param info  the plot rendering info.
 */
public StackedXYAreaRendererState(PlotRenderingInfo info) {
    super(info);
    this.seriesArea = null;
    this.line = new Line2D.Double();
    this.lastSeriesPoints = new Stack();
    this.currentSeriesPoints = new Stack();
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:13,代碼來源:StackedXYAreaRenderer.java

示例9: mouseMoved

import java.awt.geom.Line2D; //導入方法依賴的package包/類
public void mouseMoved( MouseEvent evt ) {
	if(selected || evt.isControlDown())return;
	if( map.getCursor() != cursor ) map.setCursor( cursor );
	if( points.size()==0 )return;
	drawSeg();
	double[] xyz = (double[])points.get(points.size()-1);
	Point2D.Double pt = new Point2D.Double(xyz[0], xyz[1]);
	currentSeg = new Line2D.Double( pt,
			map.getScaledPoint( evt.getPoint() ) );
	drawSeg();
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:12,代碼來源:LineSegmentsObject.java

示例10: free

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/** Returns true if a direct line between a and b will not intersect any other node. */
private boolean free(GraphNode a, GraphNode b) {
   if (a.layer() > b.layer()) { GraphNode tmp=a; a=b; b=tmp; }
   Line2D.Double line = new Line2D.Double(a.x(), a.y(), b.x(), b.y());
   for(GraphNode n:nodes) if (n!=a && n!=b && a.layer()<n.layer() && n.layer()<b.layer() && n.shape()!=null) {
      if (line.intersects(n.getBoundingBox(10,10))) return false;
   }
   return true;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:10,代碼來源:Graph.java

示例11: drag

import java.awt.geom.Line2D; //導入方法依賴的package包/類
void drag(MouseEvent e) {
	if (p0==null) { begin(e); return; }
	drawLine();
	Point2D p = map.getScaledPoint(e.getPoint());
	currentLine = new Line2D.Double(map.getScaledPoint(p0), p);
	Point2D[] pts = getPath(currentLine, 5);
	currentPath =  getGeneralPath(pts);
	drawLine();
	java.text.NumberFormat fmt = java.text.NumberFormat.getInstance();
	fmt.setMaximumFractionDigits(2);

	map.setXY(e.getPoint());
	map.getMapTools().setInfoText( map.getMapTools().getInfoText() + ", distance = " +
			fmt.format(distance(pts)) +" km");
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:16,代碼來源:GMAProfile.java

示例12: drawOccupiedPercentage

import java.awt.geom.Line2D; //導入方法依賴的package包/類
private void drawOccupiedPercentage(Color startC, Color border, boolean gradientFill, Graphics2D g2d) {

		if (remainingTime[0] != 0) {
			double x = getProcessorXY().x, y = getProcessorXY().y;
			occupiedRect = new Rectangle2D.Double(x, y, 2 * PROC_RAD, 2 * PROC_RAD * (1 - (double) remainingTime[0] / (double) totTime[0]));
			occupiedEll = new Ellipse2D.Double(x, y, 2 * PROC_RAD, 2 * PROC_RAD);
			if (gradientFill) {
				GradientPaint gp = new GradientPaint((float) x, (float) y, startC.brighter(), (float) x, (float) (y + 2 * PROC_RAD), startC.darker(),
						false);
				g2d.setPaint(gp);
			} else {
				g2d.setPaint(startC);
			}
			occupiedArea = new Area(occupiedEll);
			occupiedArea.subtract(new Area(occupiedRect));
			g2d.fill(occupiedArea);
			g2d.setPaint(Color.BLACK);
			g2d.draw(occupiedArea);

			// draw orizontal line parallel to occupation
			Line2D.Double l = new Line2D.Double(x + PROC_RAD * 2 + ELEMS_GAP, y + PROC_RAD * 2
					* (1 - (double) remainingTime[0] / (double) totTime[0]), x + PROC_RAD * 2 + 2 * ELEMS_GAP, y + PROC_RAD * 2
					* (1 - (double) remainingTime[0] / (double) totTime[0]));
			g2d.draw(l);

			// draw vertical line
			l = new Line2D.Double(x + PROC_RAD * 2 + 2 * ELEMS_GAP, y + PROC_RAD * 2 * (1 - (double) remainingTime[0] / (double) totTime[0]), x
					+ PROC_RAD * 2 + 2 * ELEMS_GAP, y + 2 * PROC_RAD + 4 * ELEMS_GAP - txtBounds.getHeight() / 2);
			g2d.draw(l);

			// draw horizontal line under text
			txtBounds.setFrame(x + PROC_RAD - txtBounds.getWidth() / 2, y + 2 * PROC_RAD + 4 * ELEMS_GAP - txtBounds.getHeight() / 2, txtBounds
					.getWidth(), txtBounds.getHeight());

			g2d.draw(txtBounds);
		}
	}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:38,代碼來源:QueueDrawer.java

示例13: drawOccupiedPercentage2

import java.awt.geom.Line2D; //導入方法依賴的package包/類
private void drawOccupiedPercentage2(Color startC, Color border, boolean gradientFill, Graphics2D g2d, int cpu) {
	//processor.setFrame(x+PROC_RAD/2 , y + cpu*PROC_RAD, 2 * PROC_RAD /2, 2 * PROC_RAD /2);

	//		if (remainingTime[cpu] != 0) {
	double x = getProcessorXY().x, y = getProcessorXY().y;
	occupiedRect = new Rectangle2D.Double(x + PROC_RAD / 2, y + cpu * PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2, 2 * PROC_RAD / 2, 2 * PROC_RAD
			* (1 - (double) remainingTime[cpu] / (double) totTime[cpu]) / 2);
	occupiedEll = new Ellipse2D.Double(x + PROC_RAD / 2, y + cpu * PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2, 2 * PROC_RAD / 2, 2 * PROC_RAD / 2);
	if (gradientFill) {
		GradientPaint gp = new GradientPaint((float) x, (float) y, startC.brighter(), (float) x, (float) (y + 2 * PROC_RAD), startC.darker(),
				false);
		g2d.setPaint(gp);
	} else {
		g2d.setPaint(startC);
	}
	occupiedArea = new Area(occupiedEll);
	occupiedArea.subtract(new Area(occupiedRect));
	g2d.fill(occupiedArea);
	g2d.setPaint(Color.BLACK);
	g2d.draw(occupiedArea);

	// draw orizontal line parallel to occupation
	Line2D.Double l = new Line2D.Double(x + PROC_RAD * 2 + ELEMS_GAP, y + cpu * PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2 + 2 * PROC_RAD
			* (1 - (double) remainingTime[cpu] / (double) totTime[cpu]) / 2,//y + PROC_RAD * 2 * (1 - (double) remainingTime / (double) totTime) /2 + ELEMS_GAP * cpu -  ELEMS_GAP /2  , 
			x + PROC_RAD * 2 + 2 * ELEMS_GAP, y + cpu * PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2 + 2 * PROC_RAD
					* (1 - (double) remainingTime[cpu] / (double) totTime[cpu]) / 2);//y + PROC_RAD * 2 * (1 - (double) remainingTime / (double) totTime) /2 + ELEMS_GAP * cpu -  ELEMS_GAP /2 );
	g2d.draw(l);

	// draw vertical line
	l = new Line2D.Double(x + PROC_RAD * 2 + 2 * ELEMS_GAP, y + cpu * PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2 + 2 * PROC_RAD
			* (1 - (double) remainingTime[cpu] / (double) totTime[cpu]) / 2, x + PROC_RAD * 2 + 2 * ELEMS_GAP, y + PROC_RAD * 2 / 2 + cpu
			* PROC_RAD + ELEMS_GAP * cpu - ELEMS_GAP / 2);
	g2d.draw(l);

	//		}
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:37,代碼來源:QueueDrawer.java

示例14: draw

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * Draws the axis.
 * 
 * @param g2  the graphics device (<code>null</code> not permitted).
 * @param cursor  the cursor position.
 * @param plotArea  the plot area (<code>null</code> not permitted).
 * @param dataArea  the data area (<code>null</code> not permitted).
 * @param edge  the edge (<code>null</code> not permitted).
 * @param plotState  collects information about the plot (<code>null</code> permitted).
 * 
 * @return the axis state (never <code>null</code>).
 */
public AxisState draw(Graphics2D g2, 
                      double cursor,
                      Rectangle2D plotArea, 
                      Rectangle2D dataArea, 
                      RectangleEdge edge,
                      PlotRenderingInfo plotState) {
    
    AxisState ret = super.draw(g2, cursor, plotArea, dataArea, edge, plotState);
    if (isAdvanceLineVisible()) {
        double xx = valueToJava2D(getRange().getUpperBound(), dataArea, edge);
        Line2D mark = null;
        g2.setStroke(getAdvanceLineStroke());
        g2.setPaint(getAdvanceLinePaint());
        if (edge == RectangleEdge.LEFT) {
            mark = new Line2D.Double(cursor, xx, cursor + dataArea.getWidth(), xx);
        }
        else if (edge == RectangleEdge.RIGHT) {
            mark = new Line2D.Double(cursor - dataArea.getWidth(), xx, cursor, xx);
        }
        else if (edge == RectangleEdge.TOP) {
            mark = new Line2D.Double(xx, cursor + dataArea.getHeight(), xx, cursor);
        }
        else if (edge == RectangleEdge.BOTTOM) {
            mark = new Line2D.Double(xx, cursor, xx, cursor - dataArea.getHeight());
        }
        g2.draw(mark);
    }
    return ret;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:42,代碼來源:CyclicNumberAxis.java

示例15: drawDomainGridline

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * Draws a grid line against the domain axis.
 * <P>
 * Note that this default implementation assumes that the horizontal axis
 * is the domain axis. If this is not the case, you will need to override
 * this method.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the area for plotting data (not yet adjusted for any
 *                  3D effect).
 * @param value  the Java2D value at which the grid line should be drawn.
 *
 * @see #drawRangeGridline(Graphics2D, CategoryPlot, ValueAxis,
 *     Rectangle2D, double)
 */
public void drawDomainGridline(Graphics2D g2,
                               CategoryPlot plot,
                               Rectangle2D dataArea,
                               double value) {

    Line2D line = null;
    PlotOrientation orientation = plot.getOrientation();

    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(dataArea.getMinX(), value,
                dataArea.getMaxX(), value);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(value, dataArea.getMinY(), value,
                dataArea.getMaxY());
    }

    Paint paint = plot.getDomainGridlinePaint();
    if (paint == null) {
        paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT;
    }
    g2.setPaint(paint);

    Stroke stroke = plot.getDomainGridlineStroke();
    if (stroke == null) {
        stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE;
    }
    g2.setStroke(stroke);

    g2.draw(line);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:49,代碼來源:AbstractCategoryItemRenderer.java


注:本文中的java.awt.geom.Line2D.Double方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。