/** * Hides (does not draw) the polygons. */ public void hidePolys() { setPolysVisible(false); }
/** * Sets the tri mesh rendered by this view. * @param mesh the tri mesh. */ public void setMesh(TriMesh mesh) { _mesh = mesh; updateMinMax(); updateBestProjectors(); repaint(); }
/** * Sets the orientation of mesh (x,y) axes. * @param orientation the orientation. */ public void setOrientation(Orientation orientation) { if (_orientation!=orientation) { _orientation = orientation; updateBestProjectors(); repaint(); } }
RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Transcaler ts = getTranscaler(); Projector px = getHorizontalProjector(); double xv0 = px.v0(); double xv1 = px.v1(); Projector py = getVerticalProjector(); double yv0 = py.v0(); double yv1 = py.v1(); _triEdgeColors = convertEdgeWeightsToColors(_triEdgeWeights); boolean haveEdgeColors = _triEdgeColors!=null; TriMesh.NodePropertyMap colorMap = null; double xaa = xshift+x(na)*xscale; double yaa = yshift+y(na)*yscale; double xbb = xshift+x(nb)*xscale; double ybb = yshift+y(nb)*yscale; double xcc = xshift+x(nc)*xscale; double ycc = yshift+y(nc)*yscale; int xa = (int)xaa; int ya = (int)yaa; drawLine(g2d,path,xd,yd,xg,yg); drawLine(g2d,path,xe,ye,xg,yg); drawLine(g2d,path,xf,yf,xg,yg); } else if (ca.equals(cb) && !cb.equals(cc)) {
private static void plot(TriMesh tm) { TriMeshView tmv = new TriMeshView(tm); tmv.setPolysVisible(true); tmv.setTriColor(Color.BLACK); tmv.setPolyColor(Color.BLUE); PlotPanel panel = new PlotPanel(); panel.setHLabel("x"); panel.setVLabel("y"); Mosaic mosaic = panel.getMosaic(); mosaic.getTile(0,0).addTiledView(tmv); PlotFrame frame = new PlotFrame(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(700,700); frame.setVisible(true); } }
/** * Sets the color of marks used to draw nodes. * @param markColor mark color. */ public void setMarkColor(Color markColor) { _markColor = markColor; repaint(); }
/** * Called when we might new realignment. */ private void updateBestProjectors() { // Assume mark sizes and line widths less than 2% of plot dimensions. // The goal is to avoid clipping big marks and wide lines. The problem // is that mark sizes and line widths are specified in screen pixels // (or points), but margins u0 and u1 are specified in normalized // coordinates, fractions of our tile's width and height. Here, we do // not know those dimensions. double u0 = 0.0; double u1 = 1.0; if ((_drawNodes && _markWidth>1.0f) || _lineWidth>1.0f) { u0 = 0.01; u1 = 0.99; } // Best projectors. Projector bhp = null; Projector bvp = null; if (_orientation==Orientation.XRIGHT_YUP) { bhp = (_xmin<_xmax)?new Projector(_xmin,_xmax,u0,u1):null; bvp = (_ymin<_ymax)?new Projector(_ymax,_ymin,u0,u1):null; } else if (_orientation==Orientation.XDOWN_YRIGHT) { bhp = (_ymin<_ymax)?new Projector(_ymin,_ymax,u0,u1):null; bvp = (_xmin<_xmax)?new Projector(_xmin,_xmax,u0,u1):null; } setBestProjectors(bhp,bvp); }
/** * Sets the width of marks used to draw nodes. * @param markWidth mark width in pixels (or points, as for a font). */ public void setMarkWidth(int markWidth) { _markWidth = markWidth; updateBestProjectors(); repaint(); }
/** * Sets the visibility (drawing or no drawing) of poly bounds. * @param drawPolyBounds true, to draw poly bounds; false, otherwise. * The default is false. */ public void setPolyBoundsVisible(boolean drawPolyBounds) { if (_drawPolyBounds!=drawPolyBounds) { _drawPolyBounds = drawPolyBounds; repaint(); } }
/** * Sets the width of lines used to draw edges of triangles. * @param lineWidth line width in pixels (or points, as for a font). */ public void setLineWidth(int lineWidth) { _lineWidth = lineWidth; updateBestProjectors(); repaint(); }
/** * Sets the color of lines used to draw edges of triangles and polygons. * @param lineColor the line color. */ public void setLineColor(Color lineColor) { _triLineColor = lineColor; _polyLineColor = lineColor; repaint(); }
/** * Shows (draws) the polygons. */ public void showPolys() { setPolysVisible(true); }
/** * Sets the color of lines used to draw edges of triangles. * @param lineColor the line color. */ public void setTriColor(Color lineColor) { _triLineColor = lineColor; repaint(); }
/** * Sets the visibility (drawing or no drawing) of nodes. * @param drawNodes true, to draw nodes; false, otherwise. * The default is true. */ public void setNodesVisible(boolean drawNodes) { if (_drawNodes!=drawNodes) { _drawNodes = drawNodes; repaint(); } }
/** * Sets the visibility (drawing or no drawing) of subdivided tris. * @param drawSubTris true, to draw subdivided tris; false, otherwise. * The default is false. */ public void setSubTrisVisible(boolean drawSubTris) { if (_drawSubTris!=drawSubTris) { _drawSubTris = drawSubTris; repaint(); } }
/** * Sets the map from triangle edges to weights. * If set, this map overrides the tri line color. * @param triEdgeWeights a map from triangle edges to weights. */ public void setTriEdgeWeights(Map<TriMesh.Edge,Float> triEdgeWeights) { _triEdgeWeights = triEdgeWeights; _triEdgeColors = null; repaint(); }
/** * Sets the visibility (drawing or no drawing) of tris. * @param drawTris true, to draw tris; false, otherwise. * The default is true. */ public void setTrisVisible(boolean drawTris) { if (_drawTris!=drawTris) { _drawTris = drawTris; repaint(); } }
/** * Sets the visibility (drawing or no drawing) of polygons. * @param drawPolys true, to draw polygons; false, otherwise. * The default is false. */ public void setPolysVisible(boolean drawPolys) { if (_drawPolys!=drawPolys) { _drawPolys = drawPolys; repaint(); } }
/** * Sets the visibility (drawing or no drawing) of tri bounds. * @param drawTriBounds true, to draw tri bounds; false, otherwise. * The default is false. */ public void setTriBoundsVisible(boolean drawTriBounds) { if (_drawTriBounds!=drawTriBounds) { _drawTriBounds = drawTriBounds; repaint(); } }
/** * Sets the color of lines used to draw edges of polygons. * @param lineColor the line color. */ public void setPolyColor(Color lineColor) { _polyLineColor = lineColor; repaint(); }