void updateCgviewSize() { cgview.setWidth(getWidth()); cgview.setHeight(getHeight()); cgview.setBackboneRadius(Math.min(getWidth(), getHeight()) * 0.35); System.out.println("repainting plasmidpanel line 161 " + (count++)); repaint(); }
/* Set up the CGView to display the plasmid */ private void initCgview() { int length = plasmid.getSequence().length(); cgview = new Cgview(length); // some optional settings cgview.setWidth(getWidth()); cgview.setHeight(getHeight()); cgview.setTitle(plasmid.getName()); cgview.setLabelPlacementQuality(100); cgview.setShowWarning(true); cgview.setLabelLineLength(8.0d); cgview.setLabelLineThickness(0.5f); cgview.setLabelShuffle(false); // create a FeatureSlot to hold sequence features FeatureSlot featureSlot = new FeatureSlot(cgview, CgviewConstants.DIRECT_STRAND); // create random sequence features List<org.autogene.core.bio.entities.Annotation> annotations = plasmid.getAnnotations(); HashMap<String, Integer> counts = new HashMap<String, Integer>(); // create the feature annotations to view in the plasmid for (int i = 0; i < annotations.size(); i++) { // update the label names such as Aapl (1) and Aapl (2) in the case that // there is more than one of the same annotation in two different locations Annotation a = annotations.get(i); String name = a.getFeature().getName(); int cur = 1; if (counts.containsKey(name)) { cur = counts.get(name); cur++; counts.put(name, cur); // Log.addText("plasmidpanel: " + name + "," + cur); } else { counts.put(name, cur); // Log.addText("plasmidpanel: " + name + "," + cur); } // simply create the feature System.out.println("ABCD creating feature with " + name + " " + cur); Feature feature = new Feature(featureSlot, (name + " (" + cur + ")")); feature.setColor( a.getScore() == 1.0 ? ColorConstants.NEUTRAL_COLOR_PERFECT_MATCH : ColorConstants.NEUTRAL_COLOR_IMPERFECT_MATCH); FeatureRange featureRange = new FeatureRange(feature, a.getStart(), a.getEnd()); } }
/** * Overridden paint component method. Update the size, then repaint the plasmid * * @param g graphics object */ public void paintComponent(Graphics g) { // super.paintComponent(g); System.out.println("paint component called"); // if((previousWidth == -1 && previousHeight == -1) || (homePanel.getWidth() != previousWidth) // || (homePanel.getHeight() != previousHeight)) { super.paintComponent(g); System.out.println("calling paint component because " + previousWidth + " " + previousHeight); setSize(homePanel.getWidth(), homePanel.getHeight()); cgview.setWidth(getWidth()); cgview.setHeight(getHeight()); cgview.setBackboneRadius(Math.min(getWidth(), getHeight()) * 0.28); cgview.setTitleFont(new Font("Georgia", Font.PLAIN, 16)); // updateCgviewSize(); cgview.draw((Graphics2D) g); previousWidth = homePanel.getWidth(); previousHeight = homePanel.getHeight(); // } }