private float getPerdua(Vector vPoints, int startIndex, int endIndex) { Line2D.Float l = new Line2D.Float( (Point2D) vPoints.elementAt(startIndex), (Point2D) vPoints.elementAt(endIndex)); float d = 0; for (int i = startIndex + 1; i < endIndex; i++) d += l.ptSegDist((Point2D) vPoints.elementAt(i)); return d; }
private float getMaxPerdua(Vector vPoints, int startIndex, int endIndex) { Line2D.Float l = new Line2D.Float( (Point2D) vPoints.elementAt(startIndex), (Point2D) vPoints.elementAt(endIndex)); double max = 0; for (int i = startIndex + 1; i < endIndex; i++) max = Math.max(max, l.ptSegDist((Point2D) vPoints.elementAt(i))); return (float) max; }
/** * Does line segment between a and b contain point (x,y)? * * @param a Point * @param b Point * @param x double * @param y double * @param maxDist double * @return true if line segment between a and b contain point (x,y) */ public static boolean hitSegment(Point a, Point b, double x, double y, double maxDist) { if (Math.min(a.x, b.x) <= x + 1 && x <= Math.max(a.x, b.x + 1) && Math.min(a.y, b.y) <= y + 1 && y <= Math.max(a.y, b.y) + 1) { Line2D.Float line = new Line2D.Float(a, b); if (line.ptLineDist(x, y) <= maxDist) return true; } return false; }
/** * @todo Refactor this. Shouldn't mix localisation logic and relation mutation logic in one method * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for method parameter * @todo-javadoc Write javadocs for return value * @todo-javadoc Write javadocs for method parameter * @param evt Describe what the parameter does * @return Describe the return value */ public boolean selectMaybe(MouseEvent evt) { boolean multiplicity = evt.isControlDown(); boolean cardinality = evt.isShiftDown(); Point point = evt.getPoint(); setSelected(_mainLine.intersects(point.getX() - 5, point.getY() - 5, 10, 10)); if (isSelected()) { double distFromP1 = Point2D.distance(_mainLine.getX1(), _mainLine.getY1(), point.getX(), point.getY()); boolean nearP1 = distFromP1 < _mainLength / 2; boolean leftChosen = (_leftIsWest && nearP1) || (!_leftIsWest && !nearP1); RelationshipRole role = leftChosen ? _rightRole : _leftRole; if (multiplicity) { // toggle multiplicity. Let's prevent the user from doing something stupid. Some // cardinalities // can't be changed. we know best etc. if (role.getRelation().isMany2Many()) { // don't allow to change cardinality of m:n relationships JOptionPane.showMessageDialog( null, "Can't change the cardinality of a many-to-many relationship", "Cardinality", JOptionPane.INFORMATION_MESSAGE); return false; } if (role.isFkPk()) { // don't allow to change cardinality of 1:1 relationships that are 1:1 because fk is also // pk JOptionPane.showMessageDialog( null, "Can't change the cardinality of a one-to-one relationship where the foreign key is also a primary key", "Cardinality", JOptionPane.INFORMATION_MESSAGE); return false; } if (role.isTargetPrimaryKey()) { JOptionPane.showMessageDialog( null, "Can't change the cardinality of a the one-side of a relationship that corresponds to a primary key", "Cardinality", JOptionPane.INFORMATION_MESSAGE); return false; } // All checks passed. Do the toggle role.setTargetMany(!role.isTargetMany()); } if (cardinality) { // toggle between uni/bidirectional role.setEnabled(!role.isEnabled()); } return true; } else { return false; } }
// p : relative to left-bottom corner public boolean canSelected(Point p) { int boxX = p.x - Constants.HIT_BOX_SIZE / 2; int boxY = p.y - Constants.HIT_BOX_SIZE / 2; int width = Constants.HIT_BOX_SIZE; int height = Constants.HIT_BOX_SIZE; Line2D.Float line = new Line2D.Float(getStart(), getEnd()); return line.intersects(boxX, boxY, width, height); }
/** Ensures all boids are inside the walls. */ public void ensureContainment() { ArrayList<Line2D.Float> walls = p.getWalls(); for (Boid boid : boids) { int intersections = 0; PVector position = boid.getPosition(); for (Line2D.Float wall : walls) { if (wall.intersectsLine(position.x, position.y, Float.MAX_VALUE, position.y)) { ++intersections; } } if (intersections % 2 == 0) { boid.setPosition(new PVector(p.width / 2.0f, p.height / 2.0f)); csp.updateEntity(boid, position); } } }
public void draw(Graphics2D g2, float x, float y) { AffineTransform transf = g2.getTransform(); Stroke oldStroke = g2.getStroke(); final double sx = transf.getScaleX(); final double sy = transf.getScaleY(); double s = 1; if (sx == sy) { // There are rounding problems due to scale factor: lines could have different // spacing... // So the increment (space+thickness) is done in using integer. s = sx; AffineTransform t = (AffineTransform) transf.clone(); t.scale(1 / sx, 1 / sy); g2.setTransform(t); } g2.setStroke( new BasicStroke((float) (s * thickness), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); float th = thickness / 2.f; final Line2D.Float line = new Line2D.Float(); float xx = x + space; xx = (float) (xx * s + (space / 2.f) * s); final int inc = (int) Math.round((space + thickness) * s); for (int i = 0; i < N; i++) { line.setLine(xx + th * s, (y - height) * s, xx + th * s, y * s); g2.draw(line); xx += inc; } if (strike) { line.setLine( (x + space) * s, (y - height / 2.f) * s, xx - s * space / 2, (y - height / 2.f) * s); g2.draw(line); } g2.setTransform(transf); g2.setStroke(oldStroke); }
/** * ****************************************************************************************** * Draws the chart * * @param axisChart * @param iAxisChartDataSet * @throws PropertyException * ******************************************************************************************* */ static void render(AxisChart axisChart, IAxisChartDataSet iAxisChartDataSet) throws PropertyException { Graphics2D g2d = axisChart.getGraphics2D(); LineChartProperties lineChartProperties = (LineChartProperties) iAxisChartDataSet.getChartTypeProperties(); lineChartProperties.validate(iAxisChartDataSet); // DataAxisProperties dataAxisProperties= (DataAxisProperties) // axisChart.getAxisProperties().getYAxisProperties(); IDataSeries iDataSeries = (IDataSeries) axisChart.getIAxisDataSeries(); // ---cache the computed values float[][] yAxisCoordinates = new float[iAxisChartDataSet.getNumberOfDataSets()] [iAxisChartDataSet.getNumberOfDataItems()]; // ---need this for image map calculation float xMapCoordinate = axisChart.getXAxis().getTickStart(); // LOOP for (int j = 0; j < iAxisChartDataSet.getNumberOfDataItems(); j++) { // LOOP for (int i = 0; i < yAxisCoordinates.length; i++) { if (iAxisChartDataSet.getValue(i, j) != Double.NaN) { yAxisCoordinates[i][j] = axisChart .getYAxis() .computeAxisCoordinate( axisChart.getYAxis().getOrigin(), iAxisChartDataSet.getValue(i, j), axisChart.getYAxis().getScaleCalculator().getMinValue()); // ---if we are generating an ImageMap, store the image coordinates if (axisChart.getGenerateImageMapFlag()) { String label; if (axisChart.getXAxis().getAxisLabelsGroup() != null) { label = axisChart.getXAxis().getAxisLabelsGroup().getTextTag(j).getText(); } else { label = null; } axisChart .getImageMap() .addImageMapArea( new CircleMapArea( xMapCoordinate, yAxisCoordinates[i][j], iAxisChartDataSet.getValue(i, j), label, iAxisChartDataSet.getLegendLabel(i))); } } else { yAxisCoordinates[i][j] = Float.NaN; } } xMapCoordinate += axisChart.getXAxis().getScalePixelWidth(); } AffineTransform originalTransform = null; double[] cornerXOffset = null; double[] cornerYOffset = null; // ---check if there are any points to display if (lineChartProperties.getShapes() != null) { // ---when centering the shapes on the points, need x and y offset to do this cornerXOffset = new double[iAxisChartDataSet.getNumberOfDataSets()]; cornerYOffset = new double[iAxisChartDataSet.getNumberOfDataSets()]; // ---get the original transform so can reset it. originalTransform = g2d.getTransform(); Rectangle2D rectangle; // LOOP // ---pre-compute the dimensions of each Shape so do not do it in loop. for (int i = 0; i < iAxisChartDataSet.getNumberOfDataSets(); i++) { if (lineChartProperties.getShapes()[i] != null) { rectangle = lineChartProperties.getShapes()[i].getBounds2D(); cornerXOffset[i] = rectangle.getWidth() / 2; cornerYOffset[i] = rectangle.getHeight() / 2; } } } // ---init for first segment Line2D.Float line = new Line2D.Float( axisChart.getXAxis().getTickStart(), yAxisCoordinates[0][0], axisChart.getXAxis().getTickStart(), yAxisCoordinates[0][0]); // ---make sure not plotting a chart with only one data point. if (yAxisCoordinates[0].length > 1) { line.y2 = yAxisCoordinates[0][1]; } // LOOP // ---draw each line to the image for (int i = 0; i < yAxisCoordinates.length; i++) { line.x1 = axisChart.getXAxis().getTickStart(); line.y1 = yAxisCoordinates[i][0]; line.x2 = line.x1; // LOOP for (int j = 1; j < yAxisCoordinates[0].length; j++) { // ---if current point on line should be drawn if (!Float.isNaN(yAxisCoordinates[i][j])) { // ---if the previous point was not drawn, no line if (Float.isNaN(yAxisCoordinates[i][j - 1])) { line.x2 += axisChart.getXAxis().getScalePixelWidth(); line.x1 = line.x2; line.y1 = yAxisCoordinates[i][j]; line.y2 = yAxisCoordinates[i][j]; continue; } line.x2 += axisChart.getXAxis().getScalePixelWidth(); line.y2 = yAxisCoordinates[i][j]; g2d.setPaint(iAxisChartDataSet.getPaint(i)); g2d.setStroke(lineChartProperties.getLineStrokes()[i]); g2d.draw(line); // ---plot the Point if (lineChartProperties.getShapes()[i] != null) { // ---translate the Shape into position. g2d.translate(line.x1 - cornerXOffset[i], line.y1 - cornerYOffset[i]); g2d.setPaint(iAxisChartDataSet.getPaint(i)); g2d.fill(lineChartProperties.getShapes()[i]); // ---translate back to the original position g2d.setTransform(originalTransform); } line.x1 = line.x2; line.y1 = line.y2; } else { if ((!Float.isNaN(yAxisCoordinates[i][j - 1])) && (lineChartProperties.getShapes()[i] != null)) { // ---translate the Shape into position. g2d.translate(line.x1 - cornerXOffset[i], line.y1 - cornerYOffset[i]); g2d.setPaint(iAxisChartDataSet.getPaint(i)); g2d.fill(lineChartProperties.getShapes()[i]); // ---translate back to the original position g2d.setTransform(originalTransform); } line.x2 += axisChart.getXAxis().getScalePixelWidth(); line.x1 = line.x2; } } // ---put the last shape on the line if ((!Float.isNaN(yAxisCoordinates[i][yAxisCoordinates[i].length - 1])) && (lineChartProperties.getShapes()[i] != null)) { // ---translate the Shape into position. g2d.translate(line.x2 - cornerXOffset[i], line.y2 - cornerYOffset[i]); g2d.setPaint(iAxisChartDataSet.getPaint(i)); g2d.fill(lineChartProperties.getShapes()[i]); // ---translate back to the original position g2d.setTransform(originalTransform); } } }
/** * Sets the CardinalityPoints attribute of the RelationLine object * * @todo refactor this duplicate code!!! */ private void setCardinalityPoints() { // compute vector of length 1 _mainLength = Point2D.distance( _mainLine.getX1(), _mainLine.getY1(), _mainLine.getX2(), _mainLine.getY2()); double vx = (_mainLine.getX2() - _mainLine.getX1()) / _mainLength; double vy = (_mainLine.getY2() - _mainLine.getY1()) / _mainLength; double cardx = 20.0 * vx; double cardy = 20.0 * vy; double arrowx = 30.0 * vx; double arrowy = 30.0 * vy; if (_leftIsWest) { _leftArrowPoint.setLocation(_mainLine.getX1() + cardx, _mainLine.getY1() + cardy); _rightArrowPoint.setLocation(_mainLine.getX2() - cardx, _mainLine.getY2() - cardy); // The left-side arrow head _temp.setLocation(_mainLine.getX1() + arrowx, _mainLine.getY1() + arrowy); _arrowTransform.setToRotation(Math.PI / 6, _leftArrowPoint.getX(), _leftArrowPoint.getY()); _arrowTransform.transform(_temp, _leftArrowPoint1); _leftArrowLine1.setLine( _leftArrowPoint.getX(), _leftArrowPoint.getY(), _leftArrowPoint1.getX(), _leftArrowPoint1.getY()); _arrowTransform.setToRotation(-Math.PI / 6, _leftArrowPoint.getX(), _leftArrowPoint.getY()); _arrowTransform.transform(_temp, _leftArrowPoint2); _leftArrowLine2.setLine( _leftArrowPoint.getX(), _leftArrowPoint.getY(), _leftArrowPoint2.getX(), _leftArrowPoint2.getY()); _arrowTransform.setToRotation(Math.PI / 2, _leftArrowPoint.getX(), _leftArrowPoint.getY()); _arrowTransform.transform(_temp, _leftCardinalityPoint); _arrowTransform.setToRotation(-Math.PI / 2, _leftArrowPoint.getX(), _leftArrowPoint.getY()); _arrowTransform.transform(_temp, _leftFkPoint); // The right-side arrow head _temp.setLocation(_mainLine.getX2() - arrowx, _mainLine.getY2() - arrowy); _arrowTransform.setToRotation(Math.PI / 6, _rightArrowPoint.getX(), _rightArrowPoint.getY()); _arrowTransform.transform(_temp, _rightArrowPoint1); _rightArrowLine1.setLine( _rightArrowPoint.getX(), _rightArrowPoint.getY(), _rightArrowPoint1.getX(), _rightArrowPoint1.getY()); _arrowTransform.setToRotation(-Math.PI / 6, _rightArrowPoint.getX(), _rightArrowPoint.getY()); _arrowTransform.transform(_temp, _rightArrowPoint2); _rightArrowLine2.setLine( _rightArrowPoint.getX(), _rightArrowPoint.getY(), _rightArrowPoint2.getX(), _rightArrowPoint2.getY()); _arrowTransform.setToRotation(-Math.PI / 2, _rightArrowPoint.getX(), _rightArrowPoint.getY()); _arrowTransform.transform(_temp, _rightCardinalityPoint); _arrowTransform.setToRotation(Math.PI / 2, _rightArrowPoint.getX(), _rightArrowPoint.getY()); _arrowTransform.transform(_temp, _rightFkPoint); } else { _leftArrowPoint.setLocation(_mainLine.getX2() - cardx, _mainLine.getY2() - cardy); _rightArrowPoint.setLocation(_mainLine.getX1() + cardx, _mainLine.getY1() + cardy); // The left-side arrow head _temp.setLocation(_mainLine.getX2() - arrowx, _mainLine.getY2() - arrowy); _arrowTransform.setToRotation(Math.PI / 6, _leftArrowPoint.getX(), _leftArrowPoint.getY()); _arrowTransform.transform(_temp, _leftArrowPoint1); _leftArrowLine1.setLine( _leftArrowPoint.getX(), _leftArrowPoint.getY(), _leftArrowPoint1.getX(), _leftArrowPoint1.getY()); _arrowTransform.setToRotation(-Math.PI / 6, _leftArrowPoint.getX(), _leftArrowPoint.getY()); _arrowTransform.transform(_temp, _leftArrowPoint2); _leftArrowLine2.setLine( _leftArrowPoint.getX(), _leftArrowPoint.getY(), _leftArrowPoint2.getX(), _leftArrowPoint2.getY()); _arrowTransform.setToRotation(Math.PI / 2, _leftArrowPoint.getX(), _leftArrowPoint.getY()); _arrowTransform.transform(_temp, _leftCardinalityPoint); _arrowTransform.setToRotation(-Math.PI / 2, _leftArrowPoint.getX(), _leftArrowPoint.getY()); _arrowTransform.transform(_temp, _leftFkPoint); // The right-side arrow head _temp.setLocation(_mainLine.getX1() + arrowx, _mainLine.getY1() + arrowy); _arrowTransform.setToRotation(Math.PI / 6, _rightArrowPoint.getX(), _rightArrowPoint.getY()); _arrowTransform.transform(_temp, _rightArrowPoint1); _rightArrowLine1.setLine( _rightArrowPoint.getX(), _rightArrowPoint.getY(), _rightArrowPoint1.getX(), _rightArrowPoint1.getY()); _arrowTransform.setToRotation(-Math.PI / 6, _rightArrowPoint.getX(), _rightArrowPoint.getY()); _arrowTransform.transform(_temp, _rightArrowPoint2); _rightArrowLine2.setLine( _rightArrowPoint.getX(), _rightArrowPoint.getY(), _rightArrowPoint2.getX(), _rightArrowPoint2.getY()); _arrowTransform.setToRotation(-Math.PI / 2, _rightArrowPoint.getX(), _rightArrowPoint.getY()); _arrowTransform.transform(_temp, _rightCardinalityPoint); _arrowTransform.setToRotation(Math.PI / 2, _rightArrowPoint.getX(), _rightArrowPoint.getY()); _arrowTransform.transform(_temp, _rightFkPoint); } }
/** * Updates all coordinates * * @todo Optimise. Some info can be cached * @todo Handle m:n (leftY/rightY etc) */ public void update() { /* * int leftY = _leftTable.getY() + _leftTable.getColumnY(_leftRole.getColumnMap().getPrimaryKey()); * int rightY; * if (!_leftRole.getRelation().isMany2Many()) { * rightY = _rightTable.getY() + _rightTable.getColumnY(_leftRole.getColumnMap().getForeignKey()); * } * else { * rightY = _rightTable.getY() + _rightTable.getColumnY(_rightRole.getColumnMap().getPrimaryKey()); * } */ int leftY = _leftTable.getY() + _leftColumnY; int rightY = _rightTable.getY() + _rightColumnY; // find out which table is farthest west (and east) JTablePanel westTable; JTablePanel eastTable; int westY; int eastY; Line2D.Float[] westLines; Line2D.Float[] eastLines; int[] westEdgeY; int[] eastEdgeY; _leftIsWest = _leftTable.getX() < _rightTable.getX(); if (_leftIsWest) { westTable = _leftTable; eastTable = _rightTable; westY = leftY; eastY = rightY; westLines = _leftLines; eastLines = _rightLines; westEdgeY = _leftEdgeY; eastEdgeY = _rightEdgeY; } else { westTable = _rightTable; eastTable = _leftTable; westY = rightY; eastY = leftY; westLines = _rightLines; eastLines = _leftLines; westEdgeY = _rightEdgeY; eastEdgeY = _leftEdgeY; } // find out whether the tables are more or less vertically aligned boolean aligned = (eastTable.getX() - westTable.getX()) < eastTable.getWidth() / 2; // TODO: handle different widths int westX; if (aligned) { westX = westTable.getX() - 10; for (int i = 0; i < westEdgeY.length; i++) { westLines[i].setLine(westX, westY, westTable.getX(), westEdgeY[i] + westTable.getY()); } } else { westX = westTable.getX() + westTable.getWidth() + 10; for (int i = 0; i < westEdgeY.length; i++) { westLines[i].setLine( westX, westY, westTable.getX() + westTable.getWidth(), westEdgeY[i] + westTable.getY()); } } int eastX = eastTable.getX() - 10; for (int i = 0; i < eastEdgeY.length; i++) { eastLines[i].setLine(eastX, eastY, eastTable.getX(), eastEdgeY[i] + eastTable.getY()); } _mainLine.setLine(westX, westY, eastX, eastY); setCardinalityPoints(); }
@Override public void draw(GameState state, Graphics2D gr, Scene scene) { float radius = 200.0f; Vec2 upper = new Vec2(fov.x, fov.y); Vec2 lower = new Vec2(fov.x, -fov.y); Vec2 upperRotated = upper.rotate(direction); Vec2 lowerRotated = lower.rotate(direction); /* Vec2 towards = target.sub( origin ); float ut = upperRotated.cross( towards ); float lt = lowerRotated.cross( towards ); boolean view = (ut <= 0 && lt >= 0 ) || (fov.x < 0.0f && ((ut >= 0 && lt >= 0) || (ut <= 0 && lt <= 0))); boolean circleInView = SteerMath.isCircleInView( origin, direction, fov, circlePos, circleRadius, circleEntirely ); */ gr.setColor(Color.orange); line.setLine( origin.x, origin.y, origin.x + upperRotated.x * radius, origin.y + upperRotated.y * radius); gr.draw(line); line.setLine( origin.x, origin.y, origin.x + lowerRotated.x * radius, origin.y + lowerRotated.y * radius); gr.draw(line); drawCircle(gr, upperRotated.mul(radius).addi(origin), 5, Color.orange); drawCircle(gr, direction.mul(radius).addi(origin), 5, Color.gray); drawCircle(gr, origin, 5, Color.white); drawCircle(gr, target, 5, Color.red); drawCircle(gr, circlePos, circleRadius, Color.yellow); /* gr.drawString( String.format( "fov: {%.2f,%.2f}", fov.x, fov.y ), 2, 12 ); gr.drawString( String.format( "origin.distanceSq(target): %.2f", origin.distanceSq( target ) ), 2, 24 ); gr.drawString( String.format( "direction.dot(towards): %.2f", direction.dot(towards) ), 2, 36 ); gr.drawString( String.format( "in view: %s", view ), 2, 48 ); gr.drawString( String.format( "upperRotated.cross( towards ): %.2f", upperRotated.cross( towards ) ), 2, 60 ); gr.drawString( String.format( "lowerRotated.cross( towards ): %.2f", lowerRotated.cross( towards ) ), 2, 72 ); gr.drawString( String.format( "isCircleInView(entirely=%s): %s", circleEntirely, circleInView ), 2, 84 ); */ Vec2 _V = circlePos.sub(origin); double _a = _V.dot(direction); // how far along the direction the sphere's center is double _b = _a * Math.tan(fovAngle); // radius of the cone at _a double _c = Math.sqrt(_V.lengthSq() - _a * _a); // distance from center of sphere to axis of the cone double _d = _c - _b; // distance from center of sphere to the surface of the cone double _e = _d * Math.cos( fovAngle); // shortest distance from center of the sphere to the surface of the cone boolean _inview = false; if (_e >= circleRadius) { // cull } else if (_e <= -circleRadius) { // totally _inview = true; } else { // partially if (!circleEntirely) { _inview = true; } } Vec2 farAlong = SteerMath.closest(origin, direction.mul(radius).addi(origin), circlePos, new Vec2()); line.setLine(origin.x, origin.y, farAlong.x, farAlong.y); gr.draw(line); line.setLine( farAlong.x + direction.y * _a, farAlong.y - direction.x * _a, farAlong.x - direction.y * _a, farAlong.y + direction.x * _a); gr.draw(line); line.setLine(farAlong.x, farAlong.y, circlePos.x, circlePos.y); gr.setColor(Color.blue); gr.draw(line); int textY = 0; gr.setColor(Color.white); gr.drawString( String.format("how far along: %.2f (expected=%.2f)", _a, farAlong.distance(origin)), 2, textY += 12); gr.drawString(String.format("radius of cone: %.2f", _b), 2, textY += 12); gr.drawString( String.format( "circle->axis of cone: %.2f (expected=%.2f)", _c, farAlong.distance(circlePos)), 2, textY += 12); gr.drawString(String.format("circle->surface of cone: %.2f", _d), 2, textY += 12); gr.drawString(String.format("shortest distance: %.2f", _e), 2, textY += 12); gr.drawString( String.format("inview(entirely=%s): %s", circleEntirely, _inview), 2, textY += 12); gr.drawString( String.format( "fov: {%.2f,%.2f}: %.2f (%.2f)", fov.x, fov.y, fovAngle, Math.toDegrees(fovAngle)), 2, textY += 12); gr.drawString( String.format( "isCircleInView: %s", SteerMath.isCircleInView( origin, direction, Math.tan(fovAngle), Math.cos(fovAngle), circlePos, circleRadius, circleEntirely)), 2, textY += 12); }
public void drawLUT(Graphics2D g2, Rectangle bound, float midfontHeight) { ByteLut lut = (ByteLut) view2DPane.getActionValue(ActionW.LUT.cmd()); if (lut != null && bound.height > 350) { if (lut.getLutTable() == null) { lut = ByteLut.grayLUT; } byte[][] table = (Boolean) view2DPane.getActionValue(ActionW.INVERSELUT.cmd()) ? lut.getInvertedLutTable() : lut.getLutTable(); float length = table[0].length; float x = bound.width - 30f; float y = bound.height / 2f - length / 2f; g2.setPaint(Color.black); Rectangle2D.Float rect = new Rectangle2D.Float(x - 11f, y - 2f, 12f, 2f); g2.draw(rect); int separation = 4; float step = length / separation; for (int i = 1; i < separation; i++) { float posY = y + i * step; rect.setRect(x - 6f, posY - 1f, 7f, 2f); g2.draw(rect); } rect.setRect(x - 11f, y + length, 12f, 2f); g2.draw(rect); rect.setRect(x - 2f, y - 2f, 23f, length + 4f); g2.draw(rect); g2.setPaint(Color.white); Line2D.Float line = new Line2D.Float(x - 10f, y - 1f, x - 1f, y - 1f); g2.draw(line); float stepWindow = (Float) view2DPane.getActionValue(ActionW.WINDOW.cmd()) / separation; float firstlevel = (Float) view2DPane.getActionValue(ActionW.LEVEL.cmd()) - stepWindow * 2f; String str = "" + (int) firstlevel; // $NON-NLS-1$ GraphicLabel.paintFontOutline( g2, str, x - g2.getFontMetrics().stringWidth(str) - 12f, y + midfontHeight); for (int i = 1; i < separation; i++) { float posY = y + i * step; line.setLine(x - 5f, posY, x - 1f, posY); g2.draw(line); str = "" + (int) (firstlevel + i * stepWindow); // $NON-NLS-1$ GraphicLabel.paintFontOutline( g2, str, x - g2.getFontMetrics().stringWidth(str) - 7, posY + midfontHeight); } line.setLine(x - 10f, y + length + 1f, x - 1f, y + length + 1f); g2.draw(line); str = "" + (int) (firstlevel + 4 * stepWindow); // $NON-NLS-1$ GraphicLabel.paintFontOutline( g2, str, x - g2.getFontMetrics().stringWidth(str) - 12, y + length + midfontHeight); rect.setRect(x - 1f, y - 1f, 21f, length + 2f); g2.draw(rect); for (int k = 0; k < length; k++) { g2.setPaint(new Color(table[0][k] & 0xff, table[1][k] & 0xff, table[2][k] & 0xff)); rect.setRect(x, y + k, 19f, 1f); g2.draw(rect); } } }
public void line(float x1, float y1, float x2, float y2) { line.setLine(x1, y1, x2, y2); strokeShape(line); }