Package gov.nasa.arc.mct.fastplot.settings

Examples of gov.nasa.arc.mct.fastplot.settings.LineSettings


    if (lineSettings != null) {
      for (String plot : lineSettings.split("\n")) {
        Map<String, LineSettings> settingsMap = new HashMap<String, LineSettings>();
       
        for (String line : plot.split("\t")) {
          LineSettings settings = new LineSettings();
         
          String[] tokens = line.split(" ");
          try {
            int i = 0;
            if (tokens.length > i) settings.setIdentifier      (                     tokens[i++] );
            if (tokens.length > i) settings.setColorIndex      (Integer.parseInt    (tokens[i++]));
            if (tokens.length > i) settings.setThickness       (Integer.parseInt    (tokens[i++]));
            if (tokens.length > i) settings.setMarker          (Integer.parseInt    (tokens[i++]));
            if (tokens.length > i) settings.setCharacter       (                     tokens[i++] );
            if (tokens.length > i) settings.setUseCharacter    (Boolean.parseBoolean(tokens[i++]));
            if (tokens.length > i) settings.setHasRegression   (Boolean.parseBoolean(tokens[i++]));
            if (tokens.length > i) settings.setRegressionPoints(Integer.parseInt    (tokens[i++]));
          } catch (Exception e) {
            logger.error("Could not parse plot line settings from persistence", e);
          }
         
          if (!settings.getIdentifier().isEmpty()) {
            settingsMap.put(settings.getIdentifier(), settings);
          }
        }
       
        lineSettingAssignments.add(settingsMap);
      }
    }
   
    /* Merge in color assignments, if specified */
    List<Map<String, Integer>> colorAssignments = getColorAssignments();
    for (int i = 0; i < Math.min(colorAssignments.size(), lineSettingAssignments.size()); i++) {
      Map<String, LineSettings> settingsMap = lineSettingAssignments.get(i);
      for (Entry<String, Integer> e : colorAssignments.get(i).entrySet()) {
        if (!settingsMap.containsKey(e.getKey())) { // Only override unspecified settings
          LineSettings settings = new LineSettings();
          settings.setIdentifier(e.getKey());
          settings.setColorIndex(e.getValue());
          settings.setMarker(e.getValue()); // Use same index for markers by default
          settingsMap.put(e.getKey(), settings);
        }
      }
    }
   
View Full Code Here


  public void persistLineSettings(List<Map<String, LineSettings>> lineSettings) {
    StringBuilder lineSettingsBuilder = new StringBuilder(lineSettings.size() * 100);
    for (Map<String, LineSettings> subPlotMap : lineSettings) {
      for (Entry<String, LineSettings> entry : subPlotMap.entrySet()) {
        LineSettings settings = entry.getValue();
       
        String id = entry.getKey();
        if ((plotViewManifestation.getTimeSystemChoices() != null) && plotViewManifestation.getTimeSystemChoices().length > 1) {
            String[] channelTypes = plotViewManifestation.getTimeSystemChoices();
            for (int i=0; i < channelTypes.length; i++) {
View Full Code Here

      if (!manifestation.isLocked()) {           
        String name = legendEntry.getComputedBaseDisplayName();
        spinnerValue = legendEntry.getNumberRegressionPoints();
        if (name.isEmpty()) name = legendEntry.getFullBaseDisplayName();

        final LineSettings settings = legendEntry.getLineSettings();
       
        // Color submenu
        String subMenuText = String.format(BUNDLE.getString("SelectColor.label"), name);
        JMenu subMenu = new JMenu(subMenuText);
        Color currentColor = legendEntry.getForeground();

        for (int i = 0; i < PlotConstants.MAX_NUMBER_OF_DATA_ITEMS_ON_A_PLOT; i++) {
          JMenuItem item = new JRadioButtonMenuItem("",
              new SolidColorIcon(PlotLineColorPalette.getColor(i)),
              (currentColor == PlotLineColorPalette.getColor(i))
              );
          final int colorIndex = i;
          item.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {       
              legendEntry.setForeground(PlotLineColorPalette.getColor(colorIndex));
              manifestation.persistPlotLineSettings();
            }         
          });
          subMenu.add(item);
        }

        add(subMenu);
       
        // Thickness submenu
        subMenuText = String.format(BUNDLE.getString("SelectThickness.label"), name);
        subMenu = new JMenu(subMenuText);
        for (int i = 1; i <= PlotConstants.MAX_LINE_THICKNESS; i++) {
          JMenuItem item = new JRadioButtonMenuItem("" + i,
              (settings.getThickness() == i));
          final int thickness = i;
          item.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {       
              settings.setThickness(thickness);
              legendEntry.setLineSettings(settings);
              manifestation.persistPlotLineSettings();
            }         
          });
          subMenu.add(item);

        }
        add(subMenu);
       
        // Marker submenu
        if (manifestation.getPlot() != null &&
          manifestation.getPlot().getPlotLineDraw().drawMarkers()) {
          subMenuText = String.format(BUNDLE.getString("SelectMarker.label"), name);
          subMenu = new JMenu(subMenuText);
          for (int i = 0; i < PlotConstants.MAX_NUMBER_OF_DATA_ITEMS_ON_A_PLOT; i++) {
            JMenuItem item = new JRadioButtonMenuItem("",
                new PlotMarkerIcon(PlotLineShapePalette.getShape(i), false),
                (settings.getMarker() == i && !settings.getUseCharacter()));
            item.setForeground(legendEntry.getForeground());
            final int marker = i;
            item.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {       
                settings.setMarker(marker);
                settings.setUseCharacter(false);
                legendEntry.setLineSettings(settings);
                manifestation.persistPlotLineSettings();
              }         
            });
            subMenu.add(item);
          }
          JMenuItem other = new JRadioButtonMenuItem(BUNDLE.getString("SelectCharacter.label"),
              settings.getUseCharacter());
          if (!settings.getCharacter().isEmpty()) {
            FontRenderContext frc = ((Graphics2D) manifestation.getGraphics()).getFontRenderContext();
            other.setIcon(new PlotMarkerIcon(
                PlotLineShapePalette.getShape(settings.getCharacter(), frc),
                PlotLineColorPalette.getColor(settings.getColorIndex()),
                false));
          }
          other.addActionListener( new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
              final CharacterDialog dialog = new CharacterDialog();
              dialog.setInitialString(settings.getCharacter());
              dialog.ok.addActionListener( new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent arg0) {
                  settings.setCharacter(dialog.field.getText().trim());
                  settings.setUseCharacter(true);
                  legendEntry.setLineSettings(settings);
                  manifestation.persistPlotLineSettings();
                }             
              });
              dialog.setVisible(true);
View Full Code Here

    for (int marker : numbers)
    for (String character : strings)
    for (boolean useCharacter : truth)
    for (boolean hasRegression : truth)
    for (int points : numbers) {   
      LineSettings source = new LineSettings();
      source.setColorIndex(color);
      source.setThickness(thickness);
      source.setMarker(marker);
      source.setCharacter(character);
      source.setUseCharacter(useCharacter);
      source.setHasRegression(hasRegression);
      source.setRegressionPoints(points);
     
      Map<String, LineSettings> map = new HashMap<String, LineSettings>();
      map.put(name, source);
      settingsToPersist.add(map);
    }         
                 
    h.persistLineSettings(settingsToPersist);
   
    List<Map<String, LineSettings>> persistedSettings = h.loadLineSettingsFromPersistence();
    int i = 0;
   
    for (Integer color : numbers)
    for (Integer thickness : numbers)
    for (Integer marker : numbers)
    for (String character : strings)
    for (boolean useCharacter : truth)
    for (boolean hasRegression : truth)
    for (Integer points : numbers) {
      LineSettings retrieved = persistedSettings.get(i++).get(name);
      Assert.assertEquals(retrieved.getColorIndex(), color);
      Assert.assertEquals(retrieved.getThickness(), thickness);
      Assert.assertEquals(retrieved.getMarker(), marker);
      Assert.assertEquals(retrieved.getCharacter(), character);
      Assert.assertEquals(retrieved.getUseCharacter(), useCharacter);
      Assert.assertEquals(retrieved.getHasRegression(), hasRegression);
      Assert.assertEquals(retrieved.getRegressionPoints(), points);
    }         
         

  }
View Full Code Here

    Mockito.when(mockPolicyManager.execute(Mockito.anyString(), Mockito.<PolicyContext> any()))
      .thenReturn(new ExecutionResult(null, false, null));
   
    Mockito.when(mockLegendEntry.getComputedBaseDisplayName()).thenReturn("test");
    Mockito.when(mockLegendEntry.getFullBaseDisplayName()).thenReturn("test");
    Mockito.when(mockLegendEntry.getLineSettings()).thenReturn(new LineSettings());
    Mockito.when(mockLegendEntry.getNumberRegressionPoints()).thenReturn(15);

   
  }
View Full Code Here

    Mockito.when(mockPolicyManager.execute(Mockito.anyString(), Mockito.<PolicyContext> any()))
    .thenReturn(new ExecutionResult(null, false, null))
 
    LegendEntryPopupMenuFactory manager = new LegendEntryPopupMenuFactory(mockPlotViewManifestation);
    for (int i = 0; i < PlotConstants.MAX_LINE_THICKNESS; i++) {
      LineSettings settings = new LineSettings();
      settings.setThickness(i + 1);
      Mockito.when(mockLegendEntry.getLineSettings()).thenReturn(settings);
 
      JPopupMenu menu = getSubMenu(manager.getPopup(mockLegendEntry), THICKNESS_SUBMENU );
     
      JRadioButtonMenuItem  item = (JRadioButtonMenuItem) menu.getComponent(i);
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.fastplot.settings.LineSettings

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.