java.awt.Rectangle#getMaxX ( )源码实例Demo

下面列出了java.awt.Rectangle#getMaxX ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dsworkbench   文件: CoordinateFormatter.java
@Override
public String valueToString(Object value) throws ParseException {
    if (value instanceof Point) {
        Point point = (Point) value;
        Village v = null;
        Rectangle dim = ServerSettings.getSingleton().getMapDimension();
        if (point.x >= dim.getMinX() && point.x <= dim.getMaxX()
                && point.y >= dim.getMinY() && point.y <= dim.getMaxY()) {
            v = DataHolder.getSingleton().getVillages()[point.x][point.y];
        }
        if (v == null) {
            return "Kein Dorf (" + point.x + "|" + point.y + ")";
        } else {
            return v.getFullName();
        }
    } else {
        return super.valueToString(value);
    }
}
 
源代码2 项目: hortonmachine   文件: OmsMapcalc.java
private static CoordinateTransform getTransform( Rectangle2D worldBounds, Rectangle imageBounds ) {
    if (worldBounds == null || worldBounds.isEmpty()) {
        throw new IllegalArgumentException("worldBounds must not be null or empty");
    }
    if (imageBounds == null || imageBounds.isEmpty()) {
        throw new IllegalArgumentException("imageBounds must not be null or empty");
    }

    double xscale = (imageBounds.getMaxX() - imageBounds.getMinX()) / (worldBounds.getMaxX() - worldBounds.getMinX());

    double xoff = imageBounds.getMinX() - xscale * worldBounds.getMinX();

    double yscale = (imageBounds.getMaxY() - imageBounds.getMinY()) / (worldBounds.getMaxY() - worldBounds.getMinY());

    double yoff = imageBounds.getMinY() - yscale * worldBounds.getMinY();

    return new AffineCoordinateTransform(new AffineTransform(xscale, 0, 0, yscale, xoff, yoff));
}
 
源代码3 项目: openAGV   文件: ViewDragScrollListener.java
private boolean isFigureCompletelyInView(Figure figure,
                                         JViewport viewport,
                                         OpenTCSDrawingView drawingView) {
  Rectangle viewPortBounds = viewport.getViewRect();
  Rectangle figureBounds = drawingView.drawingToView(figure.getDrawingArea());

  return (figureBounds.getMinX() > viewPortBounds.getMinX())
      && (figureBounds.getMinY() > viewPortBounds.getMinY())
      && (figureBounds.getMaxX() < viewPortBounds.getMaxX())
      && (figureBounds.getMaxY() < viewPortBounds.getMaxY());
}
 
public void drawCollapsedMarker(int x, int y, int width, int height) {
  // rectangle
  int rectangleWidth = MARKER_WIDTH;
  int rectangleHeight = MARKER_WIDTH;
  Rectangle rect = new Rectangle(x + (width - rectangleWidth) / 2, y + height - rectangleHeight - 3, rectangleWidth, rectangleHeight);
  g.draw(rect);

  // plus inside rectangle
  Line2D.Double line = new Line2D.Double(rect.getCenterX(), rect.getY() + 2, rect.getCenterX(), rect.getMaxY() - 2);
  g.draw(line);
  line = new Line2D.Double(rect.getMinX() + 2, rect.getCenterY(), rect.getMaxX() - 2, rect.getCenterY());
  g.draw(line);
}
 
public void drawCollapsedMarker(int x, int y, int width, int height) {
  // rectangle
  int rectangleWidth = MARKER_WIDTH;
  int rectangleHeight = MARKER_WIDTH;
  Rectangle rect = new Rectangle(x + (width - rectangleWidth) / 2, y + height - rectangleHeight - 3, rectangleWidth, rectangleHeight);
  g.draw(rect);

  // plus inside rectangle
  Line2D.Double line = new Line2D.Double(rect.getCenterX(), rect.getY() + 2, rect.getCenterX(), rect.getMaxY() - 2);
  g.draw(line);
  line = new Line2D.Double(rect.getMinX() + 2, rect.getCenterY(), rect.getMaxX() - 2, rect.getCenterY());
  g.draw(line);
}
 
源代码6 项目: sis   文件: DatumShiftGridGroup.java
/** Creates a new instance from the given {@link TileOrganizer} result. */
Region(final Tile tile) throws IOException {
    final Rectangle r = tile.getAbsoluteRegion();       // In units of the grid having finest resolution.
    final Dimension s = tile.getSubsampling();
    xmin = r.getMinX();
    xmax = r.getMaxX();
    ymin = r.getMinY();
    ymax = r.getMaxY();
    sx   = s.width;
    sy   = s.height;
}
 
源代码7 项目: audiveris   文件: WedgesBuilder.java
/**
 * Wedges look like "hair pins", composed of two converging lines.
 * <p>
 * The pair of lines of a wedge are of similar length (short or long) and rather horizontal.
 * By comparison, ending lines are isolated, long and strictly horizontal.
 */
public void buildWedges ()
{
    // Use an area on left end of a segment and look for compatible segments
    // Do the same on right end of segments
    List<SegmentInter> segments = curves.getSegments();

    for (final boolean rev : new boolean[]{true, false}) {
        Collections.sort(segments, rev ? Inters.byAbscissa : Inters.byRightAbscissa);

        for (int index = 0; index < segments.size(); index++) {
            SegmentInter s1 = segments.get(index);

            // Define the lookup area
            Rectangle area = getArea(s1.getInfo(), rev);
            double xMax = area.getMaxX();

            for (SegmentInter s2 : segments.subList(index + 1, segments.size())) {
                Point sEnd = s2.getInfo().getEnd(rev);

                if (area.contains(sEnd)) {
                    // Check compatibility
                    GradeImpacts impacts = computeImpacts(s1, s2, rev);

                    if ((impacts != null) && (impacts.getGrade() >= WedgeInter.getMinGrade())) {
                        createWedgeInter(s1, s2, rev, impacts);
                        segments.remove(s1);
                        segments.remove(s2);
                        index--;

                        break;
                    }
                } else if (sEnd.getX() > xMax) {
                    break; // Since list is sorted by abscissa
                }
            }
        }
    }
}
 
源代码8 项目: dsworkbench   文件: FarmManager.java
public int findFarmsFromBarbarians(Point pCenter, int pRadius) {
  int addCount = 0;
  invalidate();
  Ellipse2D.Double e = new Ellipse2D.Double(pCenter.x - pRadius, pCenter.y - pRadius, 2 * pRadius, 2 * pRadius);
    
  Rectangle mapDim = ServerSettings.getSingleton().getMapDimension();
  for (int i = pCenter.x - pRadius; i < pCenter.x + pRadius; i++) {
    for (int j = pCenter.y - pRadius; j < pCenter.y + pRadius; j++) {
      if (i >= mapDim.getMinX() && i <= mapDim.getMaxX()
          && j >= mapDim.getMinY() && j <= mapDim.getMaxY()) {
        if (e.contains(new Point2D.Double(i, j))) {
          Village v = DataHolder.getSingleton().getVillages()[i][j];
          if (v != null && v.getTribe().equals(Barbarians.getSingleton())) {
            FarmInformation info = addFarm(v);
            if (info.getLastReport() < 0) {
              FightReport r = ReportManager.getSingleton().findLastReportForSource(v);
              if (r != null) {
                info.updateFromReport(r);
              } else {
                info.setInitialResources();
              }
              addCount++;
            }
          }
        }
      }
    }
  }
  revalidate(true);
  return addCount;
}
 
public void drawCollapsedMarker(int x, int y, int width, int height) {
    // rectangle
    int rectangleWidth = MARKER_WIDTH;
    int rectangleHeight = MARKER_WIDTH;
    Rectangle rect = new Rectangle(x + (width - rectangleWidth) / 2, y + height - rectangleHeight - 3, rectangleWidth, rectangleHeight);
    g.draw(rect);

    // plus inside rectangle
    Line2D.Double line = new Line2D.Double(rect.getCenterX(), rect.getY() + 2, rect.getCenterX(), rect.getMaxY() - 2);
    g.draw(line);
    line = new Line2D.Double(rect.getMinX() + 2, rect.getCenterY(), rect.getMaxX() - 2, rect.getCenterY());
    g.draw(line);
}
 
源代码10 项目: rapidminer-studio   文件: PanningManager.java
/**
 * 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)));
		}
	}
}
 
源代码11 项目: chipster   文件: SelectableChartPanel.java
public Rectangle.Double translateToChart(Rectangle mouseCoords){
	
	//Screen coordinates are integers
	Point corner1 = new Point((int)mouseCoords.getMinX(), (int)mouseCoords.getMinY());
	Point corner2 = new Point((int)mouseCoords.getMaxX(), (int)mouseCoords.getMaxY());
	
	Point.Double translated1 = translateToChart(corner1);
	Point.Double translated2 = translateToChart(corner2);
	
	return createOrderedRectangle(translated1, translated2);				
}
 
源代码12 项目: niftyeditor   文件: ImageModeCanvas.java
@Override
 public void mouseMoved(MouseEvent e) {
     
     Rectangle selected = this.model.getRectangle();
     if(e.getX()>selected.getMaxX()-5 && e.getX()<selected.getMaxX()+5 
            && e.getY()>selected.getMaxY()-5
            && e.getY()<selected.getMaxY()+5
            ){
        
        e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
        curDir=DIR_SE;
    }else if(e.getX()==selected.getMinX() && (e.getY()<selected.getMaxY() && e.getY()>selected.getMinY() )){
        e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
        curDir=DIR_W;
    }else if(e.getX()==selected.getMaxX() && (e.getY()<selected.getMaxY() && e.getY()>selected.getMinY() )){
       e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
       curDir=DIR_E;
    }
    else if(e.getY()<selected.getMaxY()+5 && e.getY()>selected.getMaxY()-5 
            && (e.getX()<selected.getMaxX() && e.getX()>selected.getMinX() )){
         e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR)); 
         curDir=DIR_S;
    }
     else if(e.getY()==selected.getMinY() && (e.getX()<selected.getMaxX() && e.getX()>selected.getMinX() )){
         curDir=DIR_N;
         e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); 
}else if(e.getY()<selected.getCenterY()+10 &&
        e.getY()>selected.getCenterY()-10 && (e.getX()<(selected.getCenterX()+10) && e.getX()>selected.getCenterX()-10 )){
          e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); 
          curDir = MOV;
     }
     else{
         e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 
         curDir=NOP;
     }
   }
 
源代码13 项目: SikuliX1   文件: SxBeam.java
public void drawRayPolygon1(Graphics g, Point p, Rectangle rect) {
  if (p == null || rect == null) {
    return;
  }

  Graphics2D g2d = (Graphics2D) g;

  Rectangle r = rect;
  // corners of the target rectangle
  int cxs[] = {r.x, r.x, r.x + r.width, r.x + r.width};
  int cys[] = {r.y, r.y + r.height, r.y + r.height, r.height};

  ArrayList<Point> corners = new ArrayList<Point>();
  corners.add(new Point(r.x, r.y));
  corners.add(new Point(r.x + r.width, r.y + r.height));
  corners.add(new Point(r.x + r.width, r.y));
  corners.add(new Point(r.x, r.y + r.height));

  Collections.sort(corners, new Comparator() {
    @Override
    public int compare(Object arg0, Object arg1) {
      return (int) (current.distance((Point) arg0) - current.distance((Point) arg1));
    }
  });

  int[] xs;
  int[] ys;

  int d = 5;
  if (p.x > rect.getMinX() - 5 && p.x < rect.getMaxX() + 5
          || p.y > rect.getMinY() - 5 && p.y < rect.getMaxY() + 5) {

    xs = new int[3];
    ys = new int[3];

    xs[0] = (int) p.x;
    xs[1] = (int) corners.get(0).x;
    xs[2] = (int) corners.get(1).x;

    ys[0] = (int) p.y;
    ys[1] = (int) corners.get(0).y;
    ys[2] = (int) corners.get(1).y;

  } else {

    xs = new int[4];
    ys = new int[4];

    xs[0] = (int) p.x;
    xs[1] = (int) corners.get(2).x;
    xs[2] = (int) corners.get(0).x;
    xs[3] = (int) corners.get(1).x;

    ys[0] = (int) p.y;
    ys[1] = (int) corners.get(2).y;
    ys[2] = (int) corners.get(0).y;
    ys[3] = (int) corners.get(1).y;
  }

  Polygon shape = new Polygon(xs, ys, xs.length);

  Stroke pen = new BasicStroke(3.0F);
  g2d.setStroke(pen);
  g2d.setColor(Color.black);
  //g2d.drawPolygon(pointing_triangle);
  //g2d.drawRect(x,y,w,h);

  g2d.setColor(Color.red);
  g2d.fillPolygon(shape);
  g2d.drawRect(rect.x, rect.y, rect.width, rect.height);


}
 
源代码14 项目: netbeans   文件: OverrideEditorActions.java
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();
        }
    }
}
 
源代码15 项目: netbeans   文件: TextLayoutUtils.java
/**
     * 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;
    }
 
源代码16 项目: netbeans   文件: HighlightsViewUtils.java
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();
    }
}
 
源代码17 项目: audiveris   文件: CrossDetector.java
/**
 * Detect all cases where 2 Inters actually overlap while being in separate systems.
 *
 * @param aboves the collection of inters to process from system above
 * @param belows the collection of inters to process from system below
 */
private void detectCrossOverlaps (List<Inter> aboves,
                                  List<Inter> belows)
{
    Collections.sort(aboves, Inters.byAbscissa);
    Collections.sort(belows, Inters.byAbscissa);

    NextLeft:
    for (Inter above : aboves) {
        if (above.isRemoved()) {
            continue;
        }

        final Rectangle aboveBox = above.getBounds();

        final double xMax = aboveBox.getMaxX();

        for (Inter below : belows) {
            if (below.isRemoved()) {
                continue;
            }

            Rectangle belowBox = below.getBounds();

            if (aboveBox.intersects(belowBox)) {
                // Have a more precise look
                try {
                    if (above.overlaps(below) && below.overlaps(above)) {
                        Inter removedInter = resolveConflict(above, below);

                        if (removedInter == above) {
                            continue NextLeft;
                        }
                    }
                } catch (DeletedInterException diex) {
                    if (diex.inter == above) {
                        continue NextLeft;
                    }
                }
            } else if (belowBox.x > xMax) {
                break; // Since below list is sorted by abscissa
            }
        }
    }
}
 
源代码18 项目: audiveris   文件: Inters.java
/**
 * Lookup the provided list of interpretations for those whose bounds
 * intersect the given area.
 *
 * @param inters the list of interpretations to search for
 * @param order  if the list is already sorted by some order, this may speedup the search
 * @param area   the intersecting area
 * @return the intersected interpretations found, perhaps empty but not null
 */
public static List<Inter> intersectedInters (List<Inter> inters,
                                             GeoOrder order,
                                             Area area)
{
    List<Inter> found = new ArrayList<>();
    Rectangle bounds = area.getBounds();
    double xMax = bounds.getMaxX();
    double yMax = bounds.getMaxY();

    for (Inter inter : inters) {
        if (inter.isRemoved()) {
            continue;
        }

        Rectangle iBox = inter.getBounds();

        if (area.intersects(iBox)) {
            found.add(inter);
        } else {
            switch (order) {
            case BY_ABSCISSA:

                if (iBox.x > xMax) {
                    return found;
                }

                break;

            case BY_ORDINATE:

                if (iBox.y > yMax) {
                    return found;
                }

                break;

            case NONE:
            }
        }
    }

    return found;
}
 
源代码19 项目: TranskribusCore   文件: TrpTeiStringBuilder.java
void writeZoneForShape(SebisStringBuilder sb, ITrpShapeType s, String facsId, boolean close) {
		String id = facsId+"_"+s.getId();
		
		String zoneStr;
		if (pars.boundingBoxCoords) {
			Rectangle bb = s.getBoundingBox();
			zoneStr = "<zone ulx='"+(int)bb.getX()+"' uly='"+(int)bb.getY()+"' lrx='"+(int)bb.getMaxX()+"' lry='"+(int)bb.getMaxY()+"'";
		}
		else {
			if(StringUtils.isEmpty(s.getCoordinates())) {
				logger.error("Coordinates are empty on shape with ID = " + s.getId());
				zoneStr = "<zone points=''";
			} else {
				zoneStr = "<zone points='"+getValidZonePointsString(s.getCoordinates())+"'";
			}
		}
		
		// write type of shape:
		String type = RegionTypeUtil.getRegionType(s);
		
//		if (s instanceof TrpTextRegionType) {
//			type = "textregion";
//		}
//		else if (s instanceof TrpTextLineType) {
//			type = "line";
//		}
//		else if (s instanceof TrpWordType) {
//			type = "word";
//		}
		
		if (!type.isEmpty()) {
			zoneStr += " rendition='"+type+"'";
		}
		
		// write struct type:
		String struct = s.getStructure();
		if (struct!=null && !struct.isEmpty()) {
			zoneStr += " subtype='"+struct+"'";
		}
		
		zoneStr += " xml:id='"+id+"'";
		
		zoneStr += close ? "/>" : ">";
		
		sb.incIndent();
		sb.addLine(zoneStr);
		if (close)
			sb.decIndent();
	}
 
源代码20 项目: niftyeditor   文件: ImageModeCanvas.java
@Override
public void mouseDragged(MouseEvent e) {
    Rectangle selected = this.model.getRectangle();
    int to;
    switch (curDir) {
        case DIR_E:
            to = (int) (e.getX() - selected.getMaxX());
            if ((selected.width + to) > 0) {
                selected.width += to;
            }
            break;
        case DIR_W:
            to = (int) (selected.getMinX() - e.getX());
            if ((selected.width + to) > 0) {
                selected.x = e.getX();
                selected.width += to;

            }

            break;
        case DIR_S:
            to = (int) (e.getY() - selected.getMaxY());
            if ((selected.height + to) > 0) {
                selected.height += to;
            }
            break;
        case DIR_SE:
            to = (int) (e.getX() - selected.getMaxX());
            int toy = (int) (e.getY() - selected.getMaxY());
            if (((selected.width + to) > 0) && (selected.height + to) > 0) {
                if (e.isControlDown()) {
                    selected.height += to;
                } else {
                    selected.height += toy;
                }
                selected.width += to;

            }
            break;
        case DIR_N:
            to = (int) (selected.getMinY() - e.getY());
            if ((selected.height + to) > 0) {
                selected.height += to;
                selected.y = e.getY();
            }
            break;
        case MOV:
            selected.x = e.getX() - selected.width/2;
            selected.y = e.getY() - selected.height/2;
            break;
        default:



    }
    updateUI();
}