예제 #1
0
 /**
  * Registers ChangeListeners and sets back references in <code>PanelModel</code> and its children.
  */
 private void repair() {
   // traverse PanelModel and create all event links
   Iterator iter = panelIterator();
   while (iter.hasNext()) {
     PanelHolder ph = (PanelHolder) iter.next();
     ph.removeAllChangeListeners();
     ph.addChangeListener(this);
     ph.setPanelModel(this);
     Iterator dgIter = ph.dataGroupIterator();
     while (dgIter.hasNext()) {
       DataGroup dg = (DataGroup) dgIter.next();
       dg.removeAllChangeListeners();
       dg.addChangeListener(ph);
       dg.setPanelHolder(ph);
       dg.getXAxisHolder().removeAllChangeListeners();
       dg.getXAxisHolder().addChangeListener(dg);
       dg.getXAxisHolder().setDataGroup(dg);
       dg.getYAxisHolder().removeAllChangeListeners();
       dg.getYAxisHolder().addChangeListener(dg);
       dg.getYAxisHolder().setDataGroup(dg);
     }
     Iterator lbIter = ph.labelIterator();
     while (lbIter.hasNext()) {
       Label lb = (Label) lbIter.next();
       lb.removeAllChangeListeners();
       lb.addChangeListener(ph);
       lb.setPanelHolder(ph);
     }
     Iterator lgIter = ph.legendIterator();
     while (lgIter.hasNext()) {
       Legend lg = (Legend) lgIter.next();
       lg.removeAllChangeListeners();
       lg.addChangeListener(ph);
       lg.setPanelHolder(ph);
     }
   }
 }
예제 #2
0
  private void prepareToDraw() {

    if (forwardSlot0 != null) {
      forwardSlot0.setCgview(p);
      forwardSlot0.setFeatureThickness(featureThickness);
    }
    if (forwardSlot1 != null) {
      forwardSlot1.setCgview(p);
      forwardSlot1.setFeatureThickness(featureThickness);
    }
    if (forwardSlot2 != null) {
      forwardSlot2.setCgview(p);
      forwardSlot2.setFeatureThickness(featureThickness);
    }
    if (forwardSlot3 != null) {
      forwardSlot3.setCgview(p);
      forwardSlot3.setFeatureThickness(featureThickness);
    }
    if (forwardSlot4 != null) {
      forwardSlot4.setCgview(p);
      forwardSlot4.setFeatureThickness(featureThickness);
    }
    if (forwardSlot5 != null) {
      forwardSlot5.setCgview(p);
      forwardSlot5.setFeatureThickness(featureThickness);
    }
    if (forwardSlot6 != null) {
      forwardSlot6.setCgview(p);
      forwardSlot6.setFeatureThickness(featureThickness);
    }
    if (forwardSlot7 != null) {
      forwardSlot7.setCgview(p);
      forwardSlot7.setFeatureThickness(featureThickness);
    }

    if (reverseSlot0 != null) {
      reverseSlot0.setCgview(p);
      reverseSlot0.setFeatureThickness(featureThickness);
    }
    if (reverseSlot1 != null) {
      reverseSlot1.setCgview(p);
      reverseSlot1.setFeatureThickness(featureThickness);
    }
    if (reverseSlot2 != null) {
      reverseSlot2.setCgview(p);
      reverseSlot2.setFeatureThickness(featureThickness);
    }
    if (reverseSlot3 != null) {
      reverseSlot3.setCgview(p);
      reverseSlot3.setFeatureThickness(featureThickness);
    }
    if (reverseSlot4 != null) {
      reverseSlot4.setCgview(p);
      reverseSlot4.setFeatureThickness(featureThickness);
    }
    if (reverseSlot5 != null) {
      reverseSlot5.setCgview(p);
      reverseSlot5.setFeatureThickness(featureThickness);
    }
    if (reverseSlot6 != null) {
      reverseSlot6.setCgview(p);
      reverseSlot6.setFeatureThickness(featureThickness);
    }
    if (reverseSlot7 != null) {
      reverseSlot7.setCgview(p);
      reverseSlot7.setFeatureThickness(featureThickness);
    }

    if (restrictionSlot != null) {
      restrictionSlot.setCgview(p);
      restrictionSlot.setFeatureThickness(featureThickness);
    }

    // send settings to p
    if (showTitle) {
      p.setTitle(title);
    }
    p.setWidth(imageWidth);
    p.setHeight(imageHeight);
    p.setLabelsToKeep(MAXLABELS);
    p.setDrawTickMarks(drawTickMarks);
    p.setTitleFont(titleFont);
    p.setLabelFont(labelFont);
    p.setFeatureThickness(featureThickness);
    p.setBackboneThickness(backboneThickness);
    p.setFeatureSlotSpacing(featureSpacing);
    p.setLegendFont(legendFont);
    p.setTickLength(tickLength);
    p.setLabelLineLength(labelLineLength);
    p.setLabelPlacementQuality(labelPlacementQuality);
    p.setUseColoredLabelBackgrounds(useColoredLabelBackground);
    p.setShowBorder(showBorder);
    p.setShowShading(showShading);
    p.setShadingProportion(shadingProportion);
    p.setUseInnerLabels(useInnerLabels);
    p.setMoveInnerLabelsToOuter(moveInnerLabelsToOuter);
    p.setWarningFont(rulerFont);
    p.setRulerFont(rulerFont);

    // if not drawing labels, don't show message.
    if (!(showLabels)) {
      p.setShowWarning(false);
    }

    // set backboneRadius based on smallest image dimension
    int smallestDimension = Math.min(imageWidth, imageHeight);
    if (smallestDimension <= 750) {
      p.setBackboneRadius(0.50d * (double) smallestDimension / 2.0d);
    } else {
      p.setBackboneRadius(0.50d * 750.0d / 2.0d);
    }

    // check coloredLabels
    if (!(useColoredLabels)) {
      if (colorScheme == REGULAR) {
        p.setGlobalLabelColor((Color) MAP_ITEM_COLORS.get("titleFont"));
      } else if (colorScheme == INVERSE) {
        p.setGlobalLabelColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont"));
      }
    }

    // set map item colors
    if (colorScheme == REGULAR) {
      p.setLongTickColor((Color) MAP_ITEM_COLORS.get("tick"));
      p.setShortTickColor((Color) MAP_ITEM_COLORS.get("partialTick"));
      p.setZeroTickColor((Color) MAP_ITEM_COLORS.get("zeroLine"));
      p.setRulerFontColor((Color) MAP_ITEM_COLORS.get("rulerFont"));
      p.setBackboneColor((Color) MAP_ITEM_COLORS.get("backbone"));
      p.setTitleFontColor((Color) MAP_ITEM_COLORS.get("titleFont"));
      p.setWarningFontColor((Color) MAP_ITEM_COLORS.get("titleFont"));
      p.setBackgroundColor((Color) MAP_ITEM_COLORS.get("background"));
    } else if (colorScheme == INVERSE) {
      p.setLongTickColor((Color) MAP_ITEM_COLORS_INVERSE.get("tick"));
      p.setShortTickColor((Color) MAP_ITEM_COLORS_INVERSE.get("partialTick"));
      p.setZeroTickColor((Color) MAP_ITEM_COLORS_INVERSE.get("zeroLine"));
      p.setRulerFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("rulerFont"));
      p.setBackboneColor((Color) MAP_ITEM_COLORS_INVERSE.get("backbone"));
      p.setTitleFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont"));
      p.setWarningFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont"));
      p.setBackgroundColor((Color) MAP_ITEM_COLORS_INVERSE.get("background"));
    }

    // build legend
    if ((showLegend) && (DRAW_LEGEND_ITEMS.size() > 0)) {
      // create legend
      legend = new Legend(p);
      legend.setAllowLabelClash(allowLabelClashLegend);
      legend.setBackgroundOpacity(0.5f);
      legend.setFont(legendFont);
      legend.setPosition(legendPosition);
      if (colorScheme == REGULAR) {
        legend.setBackgroundColor((Color) MAP_ITEM_COLORS.get("background"));
        legend.setFontColor((Color) MAP_ITEM_COLORS.get("titleFont"));
      } else if (colorScheme == INVERSE) {
        legend.setBackgroundColor((Color) MAP_ITEM_COLORS_INVERSE.get("background"));
        legend.setFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont"));
      }

      LegendItem legendItem;

      Enumeration legendEntries = DRAW_LEGEND_ITEMS.keys();
      ArrayList list = new ArrayList();
      while (legendEntries.hasMoreElements()) {
        list.add(legendEntries.nextElement());
      }
      Collections.sort(list);
      Iterator i = list.iterator();

      while (i.hasNext()) {
        String key = (String) i.next();
        legendItem = new LegendItem(legend);
        legendItem.setDrawSwatch(SWATCH_SHOW);
        legendItem.setLabel((String) LEGEND_ITEM_NAMES.get(key));
        if (colorScheme == REGULAR) {
          legendItem.setSwatchColor((Color) FEATURE_COLORS.get(key));
        } else if (colorScheme == INVERSE) {
          legendItem.setSwatchColor((Color) FEATURE_COLORS_INVERSE.get(key));
        }
      }
    }

    // set message
    if (showMessage) {
      legend = new Legend(p);
      legend.setAllowLabelClash(false);
      legend.setBackgroundOpacity(0.5f);
      legend.setFont(messageFont);
      legend.setPosition(LEGEND_LOWER_RIGHT);
      LegendItem legendItem;

      if (colorScheme == REGULAR) {
        legend.setBackgroundColor((Color) MAP_ITEM_COLORS.get("background"));
        legend.setFontColor((Color) MAP_ITEM_COLORS.get("titleFont"));
        legendItem = new LegendItem(legend);
        legendItem.setLabel(message);
        legendItem.setDrawSwatch(SWATCH_NO_SHOW);
      } else if (colorScheme == INVERSE) {
        legend.setBackgroundColor((Color) MAP_ITEM_COLORS_INVERSE.get("background"));
        legend.setFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont"));
        legendItem = new LegendItem(legend);
        legendItem.setLabel(message);
        legendItem.setDrawSwatch(SWATCH_NO_SHOW);
      }
    }
  }