List of usage examples for java.lang Float MAX_VALUE
float MAX_VALUE
To view the source code for java.lang Float MAX_VALUE.
Click Source Link
From source file:org.forester.archaeopteryx.TreePanel.java
final private void paintNodeRectangular(final Graphics2D g, final PhylogenyNode node, final boolean to_pdf, final boolean dynamically_hide, final int dynamic_hiding_factor, final boolean to_graphics_file) { final boolean is_in_found_nodes = isInFoundNodes(node); if (node.isCollapse()) { if ((!node.isRoot() && !node.getParent().isCollapse()) || node.isRoot()) { paintCollapsedNode(g, node, to_graphics_file, to_pdf, is_in_found_nodes); }/*from w ww. j ava 2 s .com*/ return; } if (node.isExternal()) { ++_external_node_index; } // Confidence values if (getControlPanel().isShowBootstrapValues() && !node.isExternal() && !node.isRoot() && ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED) || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR) || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE)) && node.getBranchData().isHasConfidences()) { paintConfidenceValues(g, node, to_pdf, to_graphics_file); } // Draw a line to root: if (node.isRoot() && _phylogeny.isRooted()) { paintRootBranch(g, node.getXcoord(), node.getYcoord(), node, to_pdf, to_graphics_file); } float new_x = 0; float new_x_min = Float.MAX_VALUE; final boolean disallow_shortcutting = dynamic_hiding_factor < 40; float min_dist = 1.5f; if (!disallow_shortcutting) { // System.out.println( dynamic_hiding_factor ); if (dynamic_hiding_factor > 4000) { min_dist = 4; } else if (dynamic_hiding_factor > 1000) { min_dist = 3; } else if (dynamic_hiding_factor > 100) { min_dist = 2; } } if (!node.isExternal() && !node.isCollapse()) { boolean first_child = true; float y2 = 0.0f; final int parent_max_branch_to_leaf = getMaxBranchesToLeaf(node); for (int i = 0; i < node.getNumberOfDescendants(); ++i) { final PhylogenyNode child_node = node.getChildNode(i); int factor_x; if (!isUniformBranchLengthsForCladogram()) { factor_x = node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes(); } else { factor_x = parent_max_branch_to_leaf - getMaxBranchesToLeaf(child_node); } if (first_child) { first_child = false; y2 = node.getYcoord() - (_y_distance * (node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes())); } else { y2 += _y_distance * child_node.getNumberOfExternalNodes(); } final float x2 = calculateBranchLengthToParent(child_node, factor_x); new_x = x2 + node.getXcoord(); if (dynamically_hide && (x2 < new_x_min)) { new_x_min = x2; } final float diff_y = node.getYcoord() - y2; final float diff_x = node.getXcoord() - new_x; if (disallow_shortcutting || (diff_y > min_dist) || (diff_y < -min_dist) || (diff_x > min_dist) || (diff_x < -min_dist) || to_graphics_file || to_pdf) { paintBranchRectangular(g, node.getXcoord(), new_x, node.getYcoord(), y2, child_node, to_pdf, to_graphics_file); } child_node.setXcoord(new_x); child_node.setYcoord(y2); y2 += _y_distance * child_node.getNumberOfExternalNodes(); } } if (dynamically_hide && !is_in_found_nodes && ((node.isExternal() && (_external_node_index % dynamic_hiding_factor != 1)) || (!node.isExternal() && ((new_x_min < 20) || (_y_distance * node.getNumberOfExternalNodes() < getTreeFontSet()._fm_large.getHeight()))))) { return; } paintNodeData(g, node, to_graphics_file, to_pdf, is_in_found_nodes); paintNodeWithRenderableData(g, node, to_graphics_file, to_pdf); }
From source file:gui.images.ImageHubExplorer.java
/** * Perform multi-dimensional scaling data visualization. * * @param evt ActionEvent object.// w ww.j a va 2 s . c o m */ private void mdsVisualizeItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mdsVisualizeItemActionPerformed if (busyCalculating) { // If the system is busy calculating something, abort. return; } try { busyCalculating = true; // In the internal representation in this library, the distance matrix // is represented as upper triangular. However, the MDS component // from MDSJ requires a full square distance matrix, so we have to // generate it here from the more compact representation that is // normally used. float[][] halfDist = getDistances(); if (halfDist == null || halfDist.length == 0) { busyCalculating = false; return; } double[][] fullDist = new double[halfDist.length][halfDist.length]; for (int i = 0; i < halfDist.length; i++) { fullDist[i][i] = 0; for (int j = i + 1; j < halfDist.length; j++) { fullDist[i][j] = halfDist[i][j - i - 1]; fullDist[j][i] = halfDist[i][j - i - 1]; } } double[][] resultsReversed = MDSJ.classicalScaling(fullDist); System.out.println("MDS performed."); // Get the calculated image coordinates. imageCoordinatesXY = new float[halfDist.length][2]; float maxX = -Float.MAX_VALUE; float maxY = -Float.MAX_VALUE; float minX = Float.MAX_VALUE; float minY = Float.MAX_VALUE; for (int i = 0; i < halfDist.length; i++) { imageCoordinatesXY[i][0] = (float) resultsReversed[0][i]; imageCoordinatesXY[i][1] = (float) resultsReversed[1][i]; if (imageCoordinatesXY[i][0] > maxX) { maxX = imageCoordinatesXY[i][0]; } if (imageCoordinatesXY[i][0] < minX) { minX = imageCoordinatesXY[i][0]; } if (imageCoordinatesXY[i][1] > maxY) { maxY = imageCoordinatesXY[i][1]; } if (imageCoordinatesXY[i][1] < minY) { minY = imageCoordinatesXY[i][1]; } } // Re-scale the result to fit the window. for (int i = 0; i < halfDist.length; i++) { imageCoordinatesXY[i][0] = ((imageCoordinatesXY[i][0] - minX) / (maxX - minX)) * mdsCollectionPanel.getWidth(); imageCoordinatesXY[i][1] = ((imageCoordinatesXY[i][1] - minY) / (maxY - minY)) * mdsCollectionPanel.getHeight(); } System.out.println("Coordinates calculated."); // Find the major hubs and calculate the size of their visual display. // Offsets in case some bounding rectangles fall out of the MDS panel. float offX, offY; mdsBackgrounds = new BufferedImage[50]; if (highestHubnesses != null) { float maxFrequency = ArrayUtil.max(highestHubnesses[neighborhoodSize - 1]); float[] thumbSizes = new float[highestHubnesses[neighborhoodSize - 1].length]; ArrayList<Rectangle2D> bounds = new ArrayList<>(thumbSizes.length); ArrayList<ImagePanelWithClass> imgsMDS = new ArrayList<>(thumbSizes.length); for (int i = 0; i < thumbSizes.length; i++) { // Get the display thumbnail size. thumbSizes[i] = pointScale(highestHubnesses[neighborhoodSize - 1][i], maxFrequency, minImageScale, maxImageScale); // Calculate the offsets. if (imageCoordinatesXY[highestHubIndexes[neighborhoodSize - 1][i]][0] + thumbSizes[i] / 2 > mdsCollectionPanel.getWidth()) { offX = (thumbSizes[i] / 2 - (mdsCollectionPanel.getWidth() - imageCoordinatesXY[highestHubIndexes[neighborhoodSize - 1][i]][0])); } else if (imageCoordinatesXY[highestHubIndexes[neighborhoodSize - 1][i]][0] - thumbSizes[i] / 2 < 0) { offX = imageCoordinatesXY[highestHubIndexes[neighborhoodSize - 1][i]][0]; } else { offX = thumbSizes[i] / 2; } if (imageCoordinatesXY[highestHubIndexes[neighborhoodSize - 1][i]][1] + thumbSizes[i] / 2 > mdsCollectionPanel.getHeight()) { offY = (thumbSizes[i] / 2 - (mdsCollectionPanel.getHeight() - imageCoordinatesXY[highestHubIndexes[neighborhoodSize - 1][i]][1])); } else if (imageCoordinatesXY[highestHubIndexes[neighborhoodSize - 1][i]][1] - thumbSizes[i] / 2 < 0) { offY = imageCoordinatesXY[highestHubIndexes[neighborhoodSize - 1][i]][1]; } else { offY = thumbSizes[i] / 2; } BufferedImage thumb = thumbnails.get(highestHubIndexes[neighborhoodSize - 1][i]); ImagePanelWithClass imgPan = new ImagePanelWithClass(classColors); imgPan.addMouseListener(new NeighborSelectionListener()); imgPan.setImage(thumb, quantizedRepresentation.getLabelOf(highestHubIndexes[neighborhoodSize - 1][i]), highestHubIndexes[neighborhoodSize - 1][i]); imgsMDS.add(imgPan); bounds.add(new Rectangle2D.Float( imageCoordinatesXY[highestHubIndexes[neighborhoodSize - 1][i]][0] - offX, imageCoordinatesXY[highestHubIndexes[neighborhoodSize - 1][i]][1] - offY, thumbSizes[i], thumbSizes[i])); } mdsCollectionPanel.setImageSet(imgsMDS, bounds); // Set the background to the MDS screen. setMDSBackground(); // Refresh. mdsCollectionPanel.revalidate(); mdsCollectionPanel.repaint(); } } catch (Exception e) { System.err.println(e.getMessage()); } finally { busyCalculating = false; } }