/** * Describe what the method does * * @todo-javadoc Write javadocs for method * @todo-javadoc Write javadocs for method parameter * @param g Describe what the parameter does */ public void paint(Graphics2D g) { g.setRenderingHints(_renderHints); /* * if( isSelected() ) { * g.setColor( Color.red ); * } else { * g.setColor( Color.black ); * } */ if (_leftRole.getRelation().isMany2Many()) { g.setStroke(_dashedStroke); } else { g.setStroke(_regularStroke); } drawLineUnlessItsLengthIsZero(g, _mainLine); g.setStroke(_regularStroke); for (int i = 0; i < _leftLines.length; i++) { drawLineUnlessItsLengthIsZero(g, _leftLines[i]); } for (int i = 0; i < _rightLines.length; i++) { drawLineUnlessItsLengthIsZero(g, _rightLines[i]); } drawImage( g, getDisplayImage(_rightRole, g.getColor()), _leftCardinalityPoint.x - 8, _leftCardinalityPoint.y - 8); drawImage( g, getDisplayImage(_leftRole, g.getColor()), _rightCardinalityPoint.x - 8, _rightCardinalityPoint.y - 8); if (_rightRole.isEnabled()) { drawLineUnlessItsLengthIsZero(g, _leftArrowLine1); drawLineUnlessItsLengthIsZero(g, _leftArrowLine2); } if (_leftRole.isEnabled()) { drawLineUnlessItsLengthIsZero(g, _rightArrowLine1); drawLineUnlessItsLengthIsZero(g, _rightArrowLine2); } // draw the fk image if (!_leftRole.isOriginPrimaryKey()) { drawImage(g, _fk, _leftFkPoint.x - 6, _leftFkPoint.y - 6); } if (!_rightRole.isOriginPrimaryKey()) { drawImage(g, _fk, _rightFkPoint.x - 6, _rightFkPoint.y - 6); } }
/** * Describe what the method does * * @todo-javadoc Write javadocs for method * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for method parameter * @param g Describe what the parameter does * @param line Describe what the parameter does */ private final void drawLineUnlessItsLengthIsZero(final Graphics2D g, final Line2D line) { // Any coord is NaN if the length is zero if (!Double.isNaN(line.getP1().getX())) { g.draw(line); } }
/** * Describe what the method does * * @todo-javadoc Write javadocs for method * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for method parameter * @param g Describe what the parameter does * @param i Describe what the parameter does * @param x Describe what the parameter does * @param y Describe what the parameter does */ private final void drawImage(final Graphics2D g, final Image i, final float x, final float y) { if (!Float.isNaN(x)) { g.drawImage(i, (int) x, (int) y, null); } }