protected void draw(Graphics g, boolean hilited) { ViewState view = ViewState.getInstance(); int offsetX = view.getRx(); int offsetY = view.getRy(); int posX = getRx() - offsetX; int posY = getRy() - offsetY; int rwidth = getRwidth(); int rheight = getRheight(); double Rscale = view.getScale(); boolean zoom = (Rscale < 1.0) && view.isZoomOnHilited() && view.isHilitedObject(this); if (zoom) { rwidth /= Rscale; rheight /= Rscale; posX -= (rwidth - getRwidth()) / 2; posY -= (rheight - getRheight()) / 2; if (view.getRx() < 0) posX = posX < 0 ? 2 : posX; if (view.getRy() < 0) posY = posY <= 0 ? 2 : posY; Rscale = 1.0; } if (hilited) g.setColor(Constants.HILITE_COLOR); else g.setColor(getVisibleColor()); // double scale = view.getScale(); posX = startVertex.getRx() - offsetX; posY = startVertex.getRy() - offsetY; int posX2 = endVertex.getRx() - offsetX; int posY2 = endVertex.getRy() - offsetY; int t; if (posX > posX2) { t = posX; posX = posX2; posX2 = t; } if (posY > posY2) { t = posY; posY = posY2; posY2 = t; } if ((dashed) && ((posX != posX2) || (posY != posY2))) { int curX = posX; while (curX <= posX2) { int curX2 = curX + Constants.DASHED_LINE_DENSITY; if (curX2 > posX2) curX2 = posX2; g.drawLine(curX, posY, curX2, posY); g.drawLine(curX, posY2, curX2, posY2); curX += 2 * Constants.DASHED_LINE_DENSITY; } int curY = posY; while (curY <= posY2) { int curY2 = curY + Constants.DASHED_LINE_DENSITY; if (curY2 > posY2) curY2 = posY2; g.drawLine(posX, curY, posX, curY2); g.drawLine(posX2, curY, posX2, curY2); curY += 2 * Constants.DASHED_LINE_DENSITY; } } else g.drawRect(posX, posY, posX2 - posX, posY2 - posY); }