private void autoscale() { int stateHash = FrameManager.getStateHash(); // if(lastFrameStateHash == stateHash) return; lastStateHash = stateHash; final Collection<Track> trackList = IGV.getInstance().getAllTracks(); Map<String, List<Track>> autoscaleGroups = new HashMap<String, List<Track>>(); for (Track track : trackList) { if (!track.isVisible()) continue; String asGroup = track.getAttributeValue(AttributeManager.GROUP_AUTOSCALE); if (asGroup != null) { if (!autoscaleGroups.containsKey(asGroup)) { autoscaleGroups.put(asGroup, new ArrayList<Track>()); } autoscaleGroups.get(asGroup).add(track); } else if (track.getAutoScale()) { autoscaleGroup(Arrays.asList(track)); } } if (autoscaleGroups.size() > 0) { for (List<Track> tracks : autoscaleGroups.values()) { autoscaleGroup(tracks); } } }
/** * Paint to an offscreen graphic, e.g. a graphic for an image or svg file. * * @param g * @param rect */ public void paintOffscreen(Graphics2D g, Rectangle rect) { // Get the components of the sort by X position. Component[] components = getComponents(); Arrays.sort( components, new Comparator<Component>() { public int compare(Component component, Component component1) { return component.getX() - component1.getX(); } }); for (Component c : this.getComponents()) { if (c instanceof DataPanel) { Graphics2D g2d = (Graphics2D) g.create(); Rectangle clipRect = new Rectangle(c.getBounds()); clipRect.height = rect.height; g2d.setClip(clipRect); g2d.translate(c.getX(), 0); ((DataPanel) c).paintOffscreen(g2d, rect); } } // super.paintBorder(g); }
private void autoscaleGroup(List<Track> trackList) { List<ReferenceFrame> frames = FrameManager.isGeneListMode() ? FrameManager.getFrames() : Arrays.asList(FrameManager.getDefaultFrame()); List<Range> inViewRanges = new ArrayList<Range>(); synchronized (trackList) { for (Track track : trackList) { if (track instanceof ScalableTrack) { for (ReferenceFrame frame : frames) { Range range = ((ScalableTrack) track).getInViewRange(frame); if (range != null) { inViewRanges.add(range); } } } } if (inViewRanges.size() > 0) { Range inter = computeScale(inViewRanges); for (Track track : trackList) { DataRange dr = track.getDataRange(); float min = Math.min(0, inter.min); float base = Math.max(min, dr.getBaseline()); float max = inter.max; // Pathological case where min ~= max (no data in view) if (max - min <= (2 * Float.MIN_VALUE)) { max = min + 1; } DataRange newDR = new DataRange(min, base, max, dr.isDrawBaseline()); newDR.setType(dr.getType()); track.setDataRange(newDR); } } } }