org.scijava.vecmath.Color3f Java Examples
The following examples show how to use
org.scijava.vecmath.Color3f.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Path.java From SNT with GNU General Public License v3.0 | 6 votes |
public Content addDiscsTo3DViewer(final Image3DUniverse univ, final Color3f c, final ImagePlus colorImage) { if (!hasCircles()) return null; final Color3f[] originalColors = Pipe.getPointColors(precise_x_positions, precise_y_positions, precise_z_positions, c, colorImage); final List<Color3f> meshColors = new ArrayList<>(); final int edges = 8; final List<Point3f> allTriangles = new ArrayList<>(edges * points); for (int i = 0; i < points; ++i) { final List<Point3f> discMesh = customnode.MeshMaker.createDisc(precise_x_positions[i], precise_y_positions[i], precise_z_positions[i], tangents_x[i], tangents_y[i], tangents_z[i], radiuses[i], 8); final int pointsInDiscMesh = discMesh.size(); for (int j = 0; j < pointsInDiscMesh; ++j) meshColors.add(originalColors[i]); allTriangles.addAll(discMesh); } return univ.addTriangleMesh(allTriangles, meshColors, univ.getSafeContentName("Discs for path " + getName())); }
Example #2
Source File: Display3D.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
public Content asContent(final Display3D d3d) { double[] wi = widths; if (null == widths) { wi = new double[vs.getPoints(0).length]; Arrays.fill(wi, 2.0); } else if (widths.length != vs.length()) { Utils.log("ERROR: widths.length != VectorString3D.length()"); return null; } float transp = 1 - alpha; if (transp < 0) transp = 0; if (transp > 1) transp = 1; if (1 == transp) { Utils.log("WARNING: adding a 3D object fully transparent."); } final List<Point3f> triangles = Pipe.generateTriangles(Pipe.makeTube(vs.getPoints(0), vs.getPoints(1), vs.getPoints(2), wi, 1, 12, null), d3d.scale); final Content ct = d3d.universe.createContent(new CustomTriangleMesh(triangles, new Color3f(color), 0), title); ct.setTransparency(transp); ct.setLocked(true); return ct; }
Example #3
Source File: AreaTree.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
public MeshData generateMesh(final double scale, final int resample) { final HashMap<Layer,Area> areas = new HashMap<Layer,Area>(); synchronized (node_layer_map) { for (final Map.Entry<Layer,Set<Node<Area>>> e : node_layer_map.entrySet()) { final Area a = new Area(); for (final AreaNode nd : (Collection<AreaNode>) (Collection) e.getValue()) { if (null != nd.aw) a.add(nd.aw.getArea()); } areas.put(e.getKey(), a); } } final List<Point3f> ps = AreaUtils.generateTriangles(this, scale, resample, areas); final List<Color3f> colors = new ArrayList<Color3f>(); // Determine colors by proximity to a node, since there isn't any other way. // TODO Utils.log("WARNING: AreaTree multicolor 3D mesh is not yet implemented."); final Color3f cf = new Color3f(color); for (int i=0; i<ps.size(); i++) colors.add(cf); return new MeshData(ps, colors); }
Example #4
Source File: IJ3DRenderer.java From 3Dscript with BSD 2-Clause "Simplified" License | 5 votes |
@Override public ImageProcessor render(RenderingState kf) { int displayMode = (int)kf.getNonChannelProperty(IJ3DRenderingState.DISPLAY_MODE); int red = (int)kf.getNonChannelProperty(IJ3DRenderingState.COLOR_RED); int green = (int)kf.getNonChannelProperty(IJ3DRenderingState.COLOR_GREEN); int blue = (int)kf.getNonChannelProperty(IJ3DRenderingState.COLOR_BLUE); float transparency = (float)kf.getNonChannelProperty(IJ3DRenderingState.TRANSPARENCY); int threshold = (int)kf.getNonChannelProperty(IJ3DRenderingState.THRESHOLD); Color3f color = (red < 0 || green < 0 || blue < 0) ? null : new Color3f(red / 255f, green / 255f, blue / 255f); content.setThreshold(threshold); content.setTransparency(transparency); content.setColor(color); if(content.getType() != displayMode) content.displayAs(displayMode); CombinedTransform transform = kf.getFwdTransform(); float[] translation = transform.getTranslation(); float[] rotation = transform.getRotation(); float scale = transform.getScale(); if(Math.abs(scale - 1) > 1e-3) throw new RuntimeException("View zooming is now allowed with the 3D Viewer, please move in Z instead."); float[] fwd = rotation.clone(); Transform.applyTranslation(translation[0], translation[1], translation[2], fwd); Transform.invert(fwd); float[] m = new float[16]; System.arraycopy(fwd, 0, m, 0, 12); m[15] = 1; animateTF.set(m); animateTG.setTransform(animateTF); viewer.fireTransformationUpdated(); return takeSnapshot().getProcessor(); }
Example #5
Source File: SimpleNeuriteTracer.java From SNT with GNU General Public License v3.0 | 5 votes |
protected void addSphere(final String name, final double x, final double y, final double z, final Color color, final double radius) { if (use3DViewer) { final List<Point3f> sphere = customnode.MeshMaker.createSphere(x, y, z, radius); univ.addTriangleMesh(sphere, new Color3f(color), name); } }
Example #6
Source File: Display3DGUI.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
static public final void randomizeColors(final Image3DUniverse univ) { final ArrayList<Content> cs = new ArrayList<Content>(getOrderedContents(univ)); for (int i=0; i<cs.size(); ++i) { if (i < colors.length) { cs.get(i).setColor(new Color3f(colors[i])); } else { cs.get(i).setColor(new Color3f((float)Math.random(), (float)Math.random(), (float)Math.random())); } } // Update the color bars if something is selected: final Content content = univ.getSelected(); if (null != content) univ.fireContentChanged(content); }
Example #7
Source File: Display3D.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
static public Future<Boolean> setColor(final Displayable d, final Color color) { final Display3D d3d = getDisplay(d.getLayer().getParent()); if (null == d3d) return null; // no 3D displays open return d3d.executors.submit(new Callable<Boolean>() { @Override public Boolean call() { Content content = d3d.universe.getContent(makeTitle(d)); if (null == content) content = getProfileContent(d); if (null != content) { content.setColor(new Color3f(color)); return true; } return false; }}); }
Example #8
Source File: Display3D.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
/** Expects uncalibrated wx,wy,wz, (i.e. pixel values), to be calibrated by @param ls calibration. */ static public final Future<Content> addFatPoint(final String title, final LayerSet ls, final double wx, final double wy, final double wz, final double wr, final Color color) { final Display3D d3d = Display3D.get(ls); d3d.universe.removeContent(title); final Content ct = d3d.universe.createContent(new CustomTriangleMesh(d3d.createFatPoint(wx, wy, wz, wr, ls.getCalibrationCopy()), new Color3f(color), 0), title); ct.setLocked(true); return d3d.addContent(ct); }
Example #9
Source File: Path.java From SNT with GNU General Public License v3.0 | 4 votes |
public Content addAsLinesTo3DViewer(final Image3DUniverse univ, final Color c, final ImagePlus colorImage) { return addAsLinesTo3DViewer(univ, new Color3f(c), colorImage); }
Example #10
Source File: Path.java From SNT with GNU General Public License v3.0 | 4 votes |
public Content addAsLinesTo3DViewer(final Image3DUniverse univ, final Color3f c, final ImagePlus colorImage) { final String safeName = univ.getSafeContentName(getName() + " as lines"); return univ.addLineMesh(getPoint3fList(), c, safeName, true); }
Example #11
Source File: Path.java From SNT with GNU General Public License v3.0 | 4 votes |
public Content addDiscsTo3DViewer(final Image3DUniverse univ, final Color c, final ImagePlus colorImage) { return addDiscsTo3DViewer(univ, new Color3f(c), colorImage); }
Example #12
Source File: Path.java From SNT with GNU General Public License v3.0 | 4 votes |
synchronized public void addTo3DViewer(final Image3DUniverse univ, final Color c, final ImagePlus colorImage) { if (c == null) throw new RuntimeException("In addTo3DViewer, Color can no longer be null"); addTo3DViewer(univ, new Color3f(c), colorImage); }
Example #13
Source File: SimpleNeuriteTracer.java From SNT with GNU General Public License v3.0 | 4 votes |
public void showCorrespondencesTo(final File tracesFile, final Color c, final double maxDistance) { final PathAndFillManager pafmTraces = new PathAndFillManager(width, height, depth, (float) x_spacing, (float) y_spacing, (float) z_spacing, spacing_units); /* * FIXME: may well want to odd SWC options here, which isn't done with * the "loadGuessingType" method: */ if (!pafmTraces.loadGuessingType(tracesFile.getAbsolutePath())) { SNT.error("Failed to load traces from: " + tracesFile.getAbsolutePath()); return; } final List<Point3f> linePoints = new ArrayList<>(); // Now find corresponding points from the first one, and draw lines to // them: final ArrayList<NearPoint> cp = pathAndFillManager.getCorrespondences(pafmTraces, 2.5); int done = 0; for (final NearPoint np : cp) { if (np != null) { // SNT.log("Drawing:"); // SNT.log(np.toString()); linePoints.add(new Point3f((float) np.nearX, (float) np.nearY, (float) np.nearZ)); linePoints.add(new Point3f((float) np.closestIntersection.x, (float) np.closestIntersection.y, (float) np.closestIntersection.z)); final String ballName = univ.getSafeContentName("ball " + done); final List<Point3f> sphere = customnode.MeshMaker.createSphere(np.nearX, np.nearY, np.nearZ, Math.abs(x_spacing / 2)); univ.addTriangleMesh(sphere, new Color3f(c), ballName); } ++done; } univ.addLineMesh(linePoints, new Color3f(Color.red), "correspondences", false); for (int pi = 0; pi < pafmTraces.size(); ++pi) { final Path p = pafmTraces.getPath(pi); if (p.getUseFitted()) continue; p.addAsLinesTo3DViewer(univ, c, null); } // univ.resetView(); }
Example #14
Source File: SimpleNeuriteTracer.java From SNT with GNU General Public License v3.0 | 4 votes |
public void setSelectedColor(final Color newColor) { selectedColor = newColor; selectedColor3f = new Color3f(newColor); repaintAllPanes(); update3DViewerContents(); }
Example #15
Source File: SimpleNeuriteTracer.java From SNT with GNU General Public License v3.0 | 4 votes |
public void setDeselectedColor(final Color newColor) { deselectedColor = newColor; deselectedColor3f = new Color3f(newColor); repaintAllPanes(); update3DViewerContents(); }
Example #16
Source File: Tree.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
public MeshData(final List<Point3f> v, final List<Color3f> c) { this.verts = v; this.colors = c; }