当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle.getMaxX方法代码示例

本文整理汇总了Java中java.awt.Rectangle.getMaxX方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getMaxX方法的具体用法?Java Rectangle.getMaxX怎么用?Java Rectangle.getMaxX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Rectangle的用法示例。


在下文中一共展示了Rectangle.getMaxX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getShape

import java.awt.Rectangle; //导入方法依赖的package包/类
public Area getShape() {
    Area maskArea = new Area();
    Rectangle rect = new Rectangle(0, 0, reader.getWidth(), reader.getHeight());
    GeometryFactory gf = new GeometryFactory();
    Coordinate[] coords = new Coordinate[]{
        new Coordinate((int) rect.getMinX(), (int) rect.getMinY()),
        new Coordinate((int) rect.getMaxX(), (int) rect.getMinY()),
        new Coordinate((int) rect.getMaxX(), (int) rect.getMaxY()),
        new Coordinate((int) rect.getMinX(), (int) rect.getMaxY()),
        new Coordinate((int) rect.getMinX(), (int) rect.getMinY()),
    };
    Polygon geom = gf.createPolygon(gf.createLinearRing(coords), null);
    for (Geometry p : glayer.getGeometries()) {
        if (p.intersects(geom)) {
            int[] xPoints = new int[p.getNumPoints()];
            int[] yPoints = new int[p.getNumPoints()];
            int i = 0;
            for (Coordinate c : p.getCoordinates()) {
                xPoints[i] = (int) (c.x);
                yPoints[i++] = (int) (c.y);
            }
            maskArea.add(new Area(new java.awt.Polygon(xPoints, yPoints, p.getNumPoints())));
        }
    }
    return maskArea;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:27,代码来源:InterpolatedVectorLayer.java

示例2: getOffset

import java.awt.Rectangle; //导入方法依赖的package包/类
public int getOffset() {
	JmtCell sourceOfEdge = (JmtCell) ((DefaultPort) this.getSource()).getParent();
	Rectangle boundsSource = GraphConstants.getBounds(sourceOfEdge.getAttributes()).getBounds();
	JmtCell targetOfEdge = (JmtCell) ((DefaultPort) this.getTarget()).getParent();
	Rectangle boundsTarget = GraphConstants.getBounds(targetOfEdge.getAttributes()).getBounds();
	GraphModel graphmodel = mediator.getGraph().getModel();
	Object[] fathers = (DefaultGraphModel.getIncomingEdges(graphmodel, targetOfEdge));
	int max = (int) boundsSource.getMaxX();
	for (Object father : fathers) {
		if (father instanceof JmtEdge) {
			JmtCell sourceOfEdge2 = (JmtCell) ((DefaultPort) ((JmtEdge) father).getSource()).getParent();
			Rectangle boundsSource2 = GraphConstants.getBounds(sourceOfEdge2.getAttributes()).getBounds();
			if (sourceOfEdge != sourceOfEdge2 && boundsSource.getMaxX() < boundsTarget.getMinX() - 5
					&& boundsSource2.getMaxX() < boundsTarget.getMinX() - 5) {
				if (max < boundsSource2.getMaxX() && (int) boundsSource.getMaxX() > (int) boundsSource2.getMinX()) {
					max = (int) boundsSource2.getMaxX();
				}
			}
		}
	}
	return (int) (max - boundsSource.getMaxX());
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:23,代码来源:JmtEdge.java

示例3: rasterize

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * rasterize the mask clipped with the Rectangle scaled back to full size with an offset onto a BufferedImage
 */
public BufferedImage rasterize(Rectangle rect, int offsetX, int offsetY, double scalingFactor) {

	// create the buffered image of the size of the Rectangle
    BufferedImage image = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_BYTE_BINARY);
    GeometryFactory gf = new GeometryFactory();

    // define the clipping region in full scale
    Coordinate[] coords = new Coordinate[]{
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMaxX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMaxX() / scalingFactor)), (int) (((double) rect.getMaxY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMaxY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),};

    Polygon geom = gf.createPolygon(gf.createLinearRing(coords));

    Graphics g2d = image.getGraphics();

    g2d.setColor(Color.white);
    for (Geometry p : maskGeometries) {
    	/*if(p instanceof MultiPolygon){
    		p=p.getBoundary();
    	}*/
        if (p.intersects(geom)) {
            int[] xPoints = new int[p.getNumPoints()];//build array for x coordinates
            int[] yPoints = new int[p.getNumPoints()];//build array for y coordinates
            int i = 0;
            for (Coordinate c : p.getCoordinates()) {
                xPoints[i] = (int) ((c.x + offsetX ) * scalingFactor);
                yPoints[i] = (int) ((c.y + offsetY ) * scalingFactor);
                i++;
            }
            g2d.fillPolygon(xPoints, yPoints, i);
        }
    }
    g2d.dispose();
    return image;

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:43,代码来源:MaskGeometries.java

示例4: rasterize

import java.awt.Rectangle; //导入方法依赖的package包/类
public BufferedImage rasterize(BufferedImage image, int offsetX, int offsetY, double scalingFactor) {
    Rectangle rect = image.getRaster().getBounds();
    GeometryFactory gf = new GeometryFactory();
    Coordinate[] coords = new Coordinate[]{
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor) + offsetX), (int) (((double) rect.getMinY() / scalingFactor) + offsetY)),
        new Coordinate((int) (((double) rect.getMaxX() / scalingFactor) + offsetX), (int) (((double) rect.getMinY() / scalingFactor) + offsetY)),
        new Coordinate((int) (((double) rect.getMaxX() / scalingFactor) + offsetX), (int) (((double) rect.getMaxY() / scalingFactor) + offsetY)),
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor) + offsetX), (int) (((double) rect.getMaxY() / scalingFactor) + offsetY)),
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor) + offsetX), (int) (((double) rect.getMinY() / scalingFactor) + offsetY)),
    };
    Polygon geom = gf.createPolygon(gf.createLinearRing(coords), null);
    Graphics g2d = image.getGraphics();
    g2d.setColor(Color.WHITE);
    for (Geometry p : glayer.getGeometries()) {
        if (p.intersects(geom)) {
            int[] xPoints = new int[p.getNumPoints()];
            int[] yPoints = new int[p.getNumPoints()];
            int i = 0;
            for (Coordinate c : p.getCoordinates()) {
                xPoints[i] = (int) ((c.x - offsetX) * scalingFactor);
                yPoints[i++] = (int) ((c.y - offsetY) * scalingFactor);
            }
            g2d.fillPolygon(xPoints, yPoints, p.getNumPoints());
        }
    }
    g2d.dispose();
    return image;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:29,代码来源:InterpolatedVectorLayer.java

示例5: getOffset

import java.awt.Rectangle; //导入方法依赖的package包/类
public int getOffset() {
	JmtCell sourceOfEdge = (JmtCell) ((DefaultPort) this.getSource()).getParent();
	Rectangle boundsSource = GraphConstants.getBounds(sourceOfEdge.getAttributes()).getBounds();
	JmtCell targetOfEdge = (JmtCell) ((DefaultPort) this.getTarget()).getParent();
	Rectangle boundsTarget = GraphConstants.getBounds(targetOfEdge.getAttributes()).getBounds();
	Object[] listEdges = null;
	GraphModel graphmodel = mediator.getGraph().getModel();
	//		System.out.println("Padre: "+targetOfEdge);
	Object[] fathers = (DefaultGraphModel.getIncomingEdges(graphmodel, targetOfEdge));
	int max = (int) boundsSource.getMaxX();
	for (Object father : fathers) {
		//			System.out.println("Dentro il for");
		if (father instanceof JmtEdge) {
			JmtCell sourceOfEdge2 = (JmtCell) ((DefaultPort) ((JmtEdge) father).getSource()).getParent();
			Rectangle boundsSource2 = GraphConstants.getBounds(sourceOfEdge2.getAttributes()).getBounds();
			if (sourceOfEdge != sourceOfEdge2 && boundsSource.getMaxX() < boundsTarget.getMinX() - 5
					&& boundsSource2.getMaxX() < boundsTarget.getMinX() - 5) {
				if (max < boundsSource2.getMaxX() && (int) boundsSource.getMaxX() > (int) boundsSource2.getMinX()) {
					max = (int) boundsSource2.getMaxX();
				}
			}
		}
	}
	return (int) (max - boundsSource.getMaxX());
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:26,代码来源:JmtEdge.java

示例6: contains

import java.awt.Rectangle; //导入方法依赖的package包/类
public boolean contains(Rectangle rectangle, int row, int column) {
    if (rectangle == null)
        return true;

    double px = column * (pageWidth + W_SPACE / zoom) * getZoom();
    double py = row * (pageHeight + W_SPACE / zoom) * getZoom();
    double r = (width + W_SPACE / zoom) * getZoom() + px;
    double b = (height + W_SPACE / zoom) * getZoom() + py;
    double rx = rectangle.getX();
    double ry = rectangle.getY();

    double rr = rectangle.getMaxX();
    double rb = rectangle.getMaxY();
    if (((px <= rr) && (px >= rx)) || ((r <= rr) && (r >= rx))
            || ((rr <= r) && (rr >= px)) || ((rx <= r) && (rx >= px))) {
        return (((py <= rb) && (py >= ry)) || ((b <= rb) && (b >= ry))
                || ((rb <= b) && (rb >= py)) || ((ry <= b) && (ry >= py)));
    }
    return false;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:21,代码来源:PrintPreviewComponent.java

示例7: scrollNow

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Start scrolling.
 */
private void scrollNow() {
	if (mouseOnScreenPoint != null && target.isShowing()) {
		Point origin = target.getLocationOnScreen();
		Point relative = new Point(mouseOnScreenPoint.x - origin.x, mouseOnScreenPoint.y - origin.y);

		Rectangle visibleRect = target.getVisibleRect();

		if (!visibleRect.contains(relative)) {
			int destX = relative.x;
			if (relative.getX() < visibleRect.getMinX()) {
				destX = (int) visibleRect.getMinX() - PAN_STEP_SIZE;
			}
			if (relative.getX() > visibleRect.getMaxX()) {
				destX = (int) visibleRect.getMaxX() + PAN_STEP_SIZE;
			}

			int destY = relative.y;
			if (relative.getY() < visibleRect.getMinY()) {
				destY = (int) visibleRect.getMinY() - PAN_STEP_SIZE;
			}
			if (relative.getY() > visibleRect.getMaxY()) {
				destY = (int) visibleRect.getMaxY() + PAN_STEP_SIZE;
			}

			target.scrollRectToVisible(new Rectangle(new Point(destX, destY)));
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:32,代码来源:PanningManager.java

示例8: rasterizeJTS

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * rasterize the mask clipped with the Rectangle scaled back to full size with an offset onto a BufferedImage
 */
public BufferedImage rasterizeJTS(Rectangle rect, int offsetX, int offsetY, double scalingFactor) {

	// create the buffered image of the size of the Rectangle
    BufferedImage image = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_BYTE_BINARY);
    GeometryFactory gf = new GeometryFactory();

    // define the clipping region in full scale
    Coordinate[] coords = new Coordinate[]{
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMaxX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMaxX() / scalingFactor)), (int) (((double) rect.getMaxY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMaxY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),};

    Polygon geom = gf.createPolygon(gf.createLinearRing(coords));

    for (Geometry p : maskGeometries) {
        if (p.intersects(geom)) {
        	Geometry pg=p.intersection(geom).buffer(0);
        	//Coordinate[] coordsInter=gg.getCoordinates();
        	//Polygon pg=gf.createPolygon(coordsInter);

        	for(int x=0;x<rect.width;x++){
        		for(int y=0;y<rect.height;y++){
        			Point point=gf.createPoint(new Coordinate(rect.x+x,rect.y+y));
        			if(pg.contains(point)){
          		try{
          			image.setRGB(x,y, Color.WHITE.getRGB());
          		}catch(Exception e){
          			logger.error(e.getMessage()+"  x:"+x+"  y:"+y);
          		}
        			}
         	}
         }
     }
    }
    return image;

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:43,代码来源:MaskGeometries.java

示例9: getShape

import java.awt.Rectangle; //导入方法依赖的package包/类
public Area getShape(int width, int height) {
    Area maskArea = new Area();

    Rectangle rect = new Rectangle(0, 0, width,height);//reader.getWidth(), reader.getHeight());

    GeometryFactory gf = new GeometryFactory();
    Coordinate[] coords = new Coordinate[]{
        new Coordinate((int) rect.getMinX(), (int) rect.getMinY()),
        new Coordinate((int) rect.getMaxX(), (int) rect.getMinY()),
        new Coordinate((int) rect.getMaxX(), (int) rect.getMaxY()),
        new Coordinate((int) rect.getMinX(), (int) rect.getMaxY()),
        new Coordinate((int) rect.getMinX(), (int) rect.getMinY()),};
    Polygon geom = gf.createPolygon(gf.createLinearRing(coords), null);
    for (Geometry p : glayer.getGeometries()) {
        if (p.intersects(geom)) {
            int[] xPoints = new int[p.getNumPoints()];
            int[] yPoints = new int[p.getNumPoints()];
            int i = 0;
            for (Coordinate c : p.getCoordinates()) {
                xPoints[i] = (int) (c.x);
                yPoints[i++] = (int) (c.y);
            }
            maskArea.add(new Area(new java.awt.Polygon(xPoints, yPoints, p.getNumPoints())));
        }
    }
    return maskArea;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:28,代码来源:MaskVectorLayer.java

示例10: moveToCenterAndScale

import java.awt.Rectangle; //导入方法依赖的package包/类
public static BufferedImage moveToCenterAndScale(BufferedImage im, Consumer<BufferedImage> con, int pause)
{
    Graphics g;
    Point centerOfPixels = getCenterOfPixels(im);

    letDraw(im, con, pause);

    int width = im.getWidth();
    int heigth = im.getHeight();
    int dx = (width / 2) - centerOfPixels.x;
    int dy = (heigth / 2) - centerOfPixels.y;

    BufferedImage moved = new BufferedImage(width, heigth, BufferedImage.TYPE_INT_ARGB);
    g = moved.createGraphics();
    g.drawImage(im, dx, dy, null);

    letDraw(moved, con, pause);

    Rectangle movedBounds = getContentBounds(moved);
    int disX0 = width / 2 - movedBounds.x;
    int disY0 = heigth / 2 - movedBounds.y;
    int disX1 = (int)movedBounds.getMaxX() - width / 2;
    int disY1 = (int)movedBounds.getMaxY() - heigth / 2;
    int maxDis = Math.max(Math.max(disX0, disX1), Math.max(disY0, disY1));

    double scaleFactor = (width / 2.0 - OFFSET_TO_IMAGE_BORDER) / maxDis;

    int offset = (int)((-maxDis + width / 2) * scaleFactor) - OFFSET_TO_IMAGE_BORDER;

    BufferedImage scaled = new BufferedImage(width, heigth, BufferedImage.TYPE_INT_ARGB);
    g = scaled.createGraphics();
    g.drawImage(moved, -offset, -offset, (int)(width * scaleFactor), (int)(heigth * scaleFactor), null);

    letDraw(scaled, con, pause);

    return scaled;
}
 
开发者ID:mirkoruether,项目名称:DigitRecognizer,代码行数:38,代码来源:DigitManipulator.java

示例11: getWidth

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
     * Compute a most appropriate width of the given text layout.
     */
    public static float getWidth(TextLayout textLayout, String textLayoutText, Font font) {
        // For italic fonts the textLayout.getAdvance() includes some extra horizontal space.
        // On the other hand index2X() for TL.getCharacterCount() is width along baseline
        // so when TL ends with e.g. 'd' char the end of 'd' char is cut off.
        float width;
        int tlLen = textLayoutText.length();
        if (!font.isItalic() ||
            tlLen == 0 ||
            Character.isWhitespace(textLayoutText.charAt(tlLen - 1)) ||
            Bidi.requiresBidi(textLayoutText.toCharArray(), 0, textLayoutText.length()))
        {
            width = textLayout.getAdvance();
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("TLUtils.getWidth(\"" + CharSequenceUtilities.debugText(textLayoutText) + // NOI18N
                        "\"): Using TL.getAdvance()=" + width + // NOI18N
//                        textLayoutDump(textLayout) + 
                        '\n');
            }
        } else {
            // Compute pixel bounds (with frc being null - means use textLayout's frc; and with default bounds)
            Rectangle pixelBounds = textLayout.getPixelBounds(null, 0, 0);
            width = (float) pixelBounds.getMaxX();
            // On Mac OS X with retina displays the TL.getPixelBounds() give incorrect results. Luckily
            // TL.getAdvance() gives a correct result in that case.
            // Therefore use a minimum of both values (on all platforms).
            float tlAdvance = textLayout.getAdvance();
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("TLUtils.getWidth(\"" + CharSequenceUtilities.debugText(textLayoutText) + // NOI18N
                        "\"): Using minimum of TL.getPixelBounds().getMaxX()=" + width + // NOI18N
                        " or TL.getAdvance()=" + tlAdvance +
                        textLayoutDump(textLayout) +
                        '\n');
            }
            width = Math.min(width, tlAdvance);
        }
        
        // For RTL text the hit-info of the first char is above the hit-info of ending char.
        // However textLayout.isLeftToRight() returns true in case of mixture of LTR and RTL text
        // in a single textLayout.
        
        // Ceil the width to avoid rendering artifacts.
        width = (float) Math.ceil(width);
        return width;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:48,代码来源:TextLayoutUtils.java

示例12: paintNewline

import java.awt.Rectangle; //导入方法依赖的package包/类
static void paintNewline(Graphics2D g, Shape viewAlloc, Rectangle clipBounds,
        DocumentView docView, EditorView view, int viewStartOffset)
{
    Rectangle2D viewRectReadonly = ViewUtils.shape2Bounds(viewAlloc);
    PaintState paintState = PaintState.save(g);
    Shape origClip = g.getClip();
    try {
        JTextComponent textComponent = docView.getTextComponent();
        SplitOffsetHighlightsSequence highlights = docView.getPaintHighlights(view, 0);
        boolean showNonPrintingChars = docView.op.isNonPrintableCharactersVisible();
        float charWidth = docView.op.getDefaultCharWidth();
        boolean logFiner = ViewHierarchyImpl.PAINT_LOG.isLoggable(Level.FINER);
        if (logFiner) {
            ViewHierarchyImpl.PAINT_LOG.finer("      Newline-View-Id=" + view.getDumpId() + // NOI18N
                    ", startOffset=" + viewStartOffset + ", alloc=" + viewAlloc + '\n' // NOI18N
            );

        }
        while (highlights.moveNext()) {
            int hiStartOffset = highlights.getStartOffset();
            int hiStartSplitOffset = highlights.getStartSplitOffset();
            int hiEndOffset = Math.min(highlights.getEndOffset(), viewStartOffset + 1); // TBD
            int hiEndSplitOffset = highlights.getEndSplitOffset();
            AttributeSet attrs = highlights.getAttributes();
            if (hiStartOffset > viewStartOffset) { // HL above newline
                break;
            }

            double startX = viewRectReadonly.getX() + hiStartSplitOffset * charWidth;
            double endX = (hiEndOffset > viewStartOffset)
                    ? viewRectReadonly.getMaxX()
                    : Math.min(viewRectReadonly.getX() + hiEndSplitOffset * charWidth, viewRectReadonly.getMaxX());
            Rectangle2D.Double renderPartRect = new Rectangle2D.Double(startX, viewRectReadonly.getY(), endX - startX, viewRectReadonly.getHeight());
            fillBackground(g, renderPartRect, attrs, textComponent);
            boolean hitsClip = (clipBounds == null) || renderPartRect.intersects(clipBounds);
            if (hitsClip) {
                // First render background and background related highlights
                // Do not g.clip() before background is filled since otherwise there would be
                // painting artifacts for italic fonts (one-pixel slanting lines) at certain positions.
                // Clip to part's alloc since textLayout.draw() renders fully the whole text layout
                g.clip(renderPartRect);
                paintBackgroundHighlights(g, renderPartRect, attrs, docView);
                // Render foreground with proper color
                g.setColor(HighlightsViewUtils.validForeColor(attrs, textComponent));
                Object strikeThroughValue = (attrs != null)
                        ? attrs.getAttribute(StyleConstants.StrikeThrough)
                        : null;
                if (showNonPrintingChars && hiStartSplitOffset == 0) { // First part => render newline char visible representation
                    TextLayout textLayout = docView.op.getNewlineCharTextLayout();
                    if (textLayout != null) {
                        paintTextLayout(g, renderPartRect, textLayout, docView);
                    }
                }
                if (strikeThroughValue != null) {
                    paintStrikeThrough(g, viewRectReadonly, strikeThroughValue, attrs, docView);
                }
                g.setClip(origClip);
            }
            if (logFiner) {
                ViewHierarchyImpl.PAINT_LOG.finer("        Highlight <" + 
                        hiStartOffset + '_' + hiStartSplitOffset + "," + // NOI18N
                        hiEndOffset + '_' + hiEndSplitOffset + ">, Color=" + // NOI18N
                        ViewUtils.toString(g.getColor()) + '\n'); // NOI18N
            }
            if (clipBounds != null && (renderPartRect.getX() > clipBounds.getMaxX())) {
                break;
            }
        }
    } finally {
        g.setClip(origClip);
        paintState.restore();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:74,代码来源:HighlightsViewUtils.java

示例13: actionPerformed

import java.awt.Rectangle; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent evt, JTextComponent target) {
    if (target != null) {
        Caret caret = target.getCaret();
        BaseDocument doc = (BaseDocument)target.getDocument();
        try {
            int dot = caret.getDot();
            // #232675: if bounds are defined, use them rather than line start/end
            Object o = target.getClientProperty(PROP_NAVIGATE_BOUNDARIES);
            PositionRegion bounds = null;
            int lineStartPos = Utilities.getRowStart(target, dot);
            
            if (o instanceof PositionRegion) {
                bounds = (PositionRegion)o;
                int start = bounds.getStartOffset();
                int end = bounds.getEndOffset();
                int boundLineStart = Utilities.getRowStart(target, start);
                // refinement: only use the boundaries if the caret is at the same line
                // as boundary start; otherwise ignore the boundary and use document lines.
                if (boundLineStart == lineStartPos && dot > start && dot <= end) {
                    // move to the region start
                    dot = start;
                } else {
                    bounds = null;
                }
            }
            
            if (bounds == null) {
                if (homeKeyColumnOne) { // to first column
                    dot = lineStartPos;
                } else { // either to line start or text start
                    int textStartPos = Utilities.getRowFirstNonWhite(doc, lineStartPos);
                    if (textStartPos < 0) { // no text on the line
                        textStartPos = Utilities.getRowEnd(target, lineStartPos);
                    }
                    if (dot == lineStartPos) { // go to the text start pos
                        dot = textStartPos;
                    } else if (dot <= textStartPos) {
                        dot = lineStartPos;
                    } else {
                        dot = textStartPos;
                    }
                }
            }
            // For partial view hierarchy check bounds
            dot = Math.max(dot, target.getUI().getRootView(target).getStartOffset());
            String actionName = (String) getValue(Action.NAME);
            boolean select = selectionBeginLineAction.equals(actionName)
                    || selectionLineFirstColumnAction.equals(actionName);
            
            // If possible scroll the view to its begining horizontally
            // to ease user's orientation in the code.
            Rectangle r = target.modelToView(dot);
            Rectangle visRect = target.getVisibleRect();
            if (r.getMaxX() < visRect.getWidth()) {
                r.x = 0;
                target.scrollRectToVisible(r);
            }
            target.putClientProperty("navigational.action", SwingConstants.WEST);
            if (select) {
                caret.moveDot(dot);
            } else {
                caret.setDot(dot);
            }
        } catch (BadLocationException e) {
            target.getToolkit().beep();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:69,代码来源:OverrideEditorActions.java

示例14: rasterMaskJTS

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * rasterize the mask clipped with the Rectangle scaled back to full size with an offset onto a BufferedImage
 */
public int[] rasterMaskJTS(Rectangle rect, int offsetX, int offsetY, double scalingFactor) {

	// create the buffered image of the size of the Rectangle
    int[] mask = new int[rect.width* rect.height];
    GeometryFactory gf = new GeometryFactory();

    // define the clipping region in full scale
    Coordinate[] coords = new Coordinate[]{
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMaxX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMaxX() / scalingFactor)), (int) (((double) rect.getMaxY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMaxY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),};

    Polygon geom = gf.createPolygon(gf.createLinearRing(coords));
    PreparedPolygon ppol=new PreparedPolygon(geom);

    int numPix=rect.width*rect.height;
    for (Geometry p : maskGeometries) {
        if (ppol.intersects(p)) {
        	Geometry pg=p.intersection(geom).buffer(0);
        	IndexedPointInAreaLocator locator=new IndexedPointInAreaLocator(pg);


        	int x=0;
        	int y=0;

        	for(int ii=0;ii<numPix;ii++){
        		if(ii%rect.width==0){
        			x=0;
        			y++;
        		}
    			//Point point=gf.createPoint(new Coordinate(rect.x+x,rect.y+y));
    			//PreparedPoint ppoint=new PreparedPoint(point);
    			//if(ppoint.within(pg)){
        		int loc=locator.locate(new Coordinate(rect.x+x,rect.y+y));
        		if(loc==Location.INTERIOR||loc==Location.BOUNDARY)
         		try{
         			mask[x]=1;
         		}catch(Exception e){
         			logger.warn(e.getMessage()+"  x:"+x+"  y:"+y);
         		}
    			}
         }
     //}
    }
    return mask;

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:53,代码来源:MaskGeometries.java

示例15: moveLocation

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Moves the current location by a given amount.
 *
 * @param dr the number of rows by which to move the location
 * @param dc the number of columns by which to move the location
 */
public void moveLocation(int dr, int dc) {
    Location newLocation = new Location(currentLocation.getRow() + dr,
            currentLocation.getCol() + dc);
    if (!grid.isValid(newLocation))
        return;

    currentLocation = newLocation;

    JViewport viewPort = getEnclosingViewport();
    if (isPannableUnbounded()) {
        if (originRow > currentLocation.getRow())
            originRow = currentLocation.getRow();
        if (originCol > currentLocation.getCol())
            originCol = currentLocation.getCol();
        Dimension dim = viewPort.getSize();
        int rows = dim.height / (cellSize + 1);
        int cols = dim.width / (cellSize + 1);
        if (originRow + rows - 1 < currentLocation.getRow())
            originRow = currentLocation.getRow() - rows + 1;
        if (originCol + rows - 1 < currentLocation.getCol())
            originCol = currentLocation.getCol() - cols + 1;
    } else if (viewPort != null) {
        int dx = 0;
        int dy = 0;
        Point p = pointForLocation(currentLocation);
        Rectangle locRect = new Rectangle(p.x - cellSize / 2, p.y
                - cellSize / 2, cellSize + 1, cellSize + 1);

        Rectangle viewRect = viewPort.getViewRect();
        if (!viewRect.contains(locRect)) {
            while (locRect.x < viewRect.x + dx)
                dx -= cellSize + 1;
            while (locRect.y < viewRect.y + dy)
                dy -= cellSize + 1;
            while (locRect.getMaxX() > viewRect.getMaxX() + dx)
                dx += cellSize + 1;
            while (locRect.getMaxY() > viewRect.getMaxY() + dy)
                dy += cellSize + 1;

            Point pt = viewPort.getViewPosition();
            pt.x += dx;
            pt.y += dy;
            viewPort.setViewPosition(pt);
        }
    }
    repaint();
    showTip(getToolTipText(currentLocation),
            pointForLocation(currentLocation));
}
 
开发者ID:CBSkarmory,项目名称:AWGW,代码行数:56,代码来源:GridPanel.java


注:本文中的java.awt.Rectangle.getMaxX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。