Пример #1
0
  protected void addIndexCodingAndBitmasks(Band smBand) {
    final IndexCoding coding = new IndexCoding("SM_coding");
    final MetadataAttribute land =
        coding.addSample("LAND", 0, "Not cloud, shadow or edge AND land");
    final MetadataAttribute flooded =
        coding.addSample("FLOODED", 1, "Not land and not cloud, shadow or edge");
    final MetadataAttribute suspect = coding.addSample("SUSPECT", 2, "Cloud shadow or cloud edge");
    final MetadataAttribute cloud = coding.addSample("CLOUD", 3, "Cloud");
    final MetadataAttribute water = coding.addSample("WATER", 4, "Not land");
    final MetadataAttribute snow = coding.addSample("SNOW", 5, "Snow");
    final MetadataAttribute invalid = coding.addSample("INVALID", 6, "Invalid");
    final Product product = smBand.getProduct();
    product.getIndexCodingGroup().add(coding);
    smBand.setSampleCoding(coding);
    final ColorPaletteDef.Point[] points =
        new ColorPaletteDef.Point[] {
          new ColorPaletteDef.Point(0, Color.GREEN.darker(), "land"),
          new ColorPaletteDef.Point(1, Color.BLUE, "flooded"),
          new ColorPaletteDef.Point(2, Color.ORANGE, "suspect"),
          new ColorPaletteDef.Point(3, Color.GRAY, "cloud"),
          new ColorPaletteDef.Point(4, Color.BLUE.darker(), "water"),
          new ColorPaletteDef.Point(5, Color.LIGHT_GRAY, "snow"),
          new ColorPaletteDef.Point(6, Color.RED, "invalid")
        };
    smBand.setImageInfo(new ImageInfo(new ColorPaletteDef(points)));

    addMask(land, "SM == 0", Color.GREEN.darker(), product);
    addMask(flooded, "SM == 1", Color.BLUE, product);
    addMask(suspect, "SM == 2", Color.ORANGE, product);
    addMask(cloud, "SM == 3", Color.GRAY, product);
    addMask(water, "SM == 4", Color.BLUE.darker(), product);
    addMask(snow, "SM == 5", Color.LIGHT_GRAY, product);
    addMask(invalid, "SM == 6", Color.RED, product);
  }
Пример #2
0
  private void paintHelyxProgressBar(Graphics g) {
    int leftPadding = 15;
    int topPadding = 205;
    int splashWidth = getSplashScreen().getSize().width;
    int width = Math.min(10 * counter, splashWidth - (leftPadding * 2));

    g.setColor(isHelyxOS ? Color.BLUE.darker() : Color.RED.darker());
    g.fillRect(leftPadding, topPadding, width, 2);
    g.setColor(isHelyxOS ? Color.BLUE.brighter() : Color.RED.brighter());
    g.fillRect(leftPadding, topPadding, width, 1);
  }
Пример #3
0
 public static void main(String args[]) {
   StreetMap map =
       new StreetMap.Builder(new Point(50, 50), new Point(100, 100))
           .landColor(Color.GRAY)
           .waterColor(Color.BLUE.brighter())
           .build();
 }
  public void render(Graphics2D g, Dimension d) {
    int n = this.problemScore.getAttempts();
    n += this.problemScore.getPendings();
    String text = "" + n;
    Color baseColor;
    if (this.problemScore.isSolved()) {
      baseColor = Color.GREEN;
      text += " / " + this.problemScore.getSolutionTime();
    } else if (this.problemScore.isPending()) {
      baseColor = Color.BLUE.brighter();
    } else if (this.problemScore.getAttempts() > 0) {
      baseColor = Color.RED;
    } else {
      baseColor = new Color(0, 0, 0, 0);
    }
    // g.fillRect(0, 0, d.width, d.height);
    ShadedRectangle.drawShadedRoundRect(g, baseColor, 0, 0, d.width, d.height, d.height / 3f);
    g.setColor(Color.BLACK);

    Font backup = g.getFont();
    double magicScale = d.height / 20f;
    Font nfont = backup.deriveFont(AffineTransform.getScaleInstance(magicScale, magicScale));
    Rectangle2D rect = new Rectangle2D.Float(0, 0, d.width, d.height);
    Utility.drawString3D(g, text, rect, nfont, Alignment.center);
  }
Пример #5
0
  @Override
  public void draw(Graphics2D g2d, Surface s) {

    g2d.setPaint(getColor());
    g2d.fill(getSurface());

    if (getHover() && !selected) {
      Stroke outl = new BasicStroke(2f);
      g2d.setStroke(outl);
      if (getColor() != Color.red) g2d.setPaint(Color.red);
      else g2d.setPaint(Color.BLACK);
      g2d.drawPolygon(getSurface());
    } else if (selected) {
      float[] dash = {4f, 0f, 2f};
      BasicStroke outl =
          new BasicStroke(
              2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash, getFramesAlive() * .2f);
      g2d.setStroke(outl);

      if (ownedby.equals(Player.NONE)) {
        g2d.setPaint(Color.black);
      } else if (ownedby.equals(Player.COMPUTER)) {
        g2d.setPaint(Color.RED);
      } else if (ownedby.equals(Player.PLAYER)) {
        g2d.setPaint(Color.BLUE);
      }

      g2d.drawPolygon(getSurface());
    }

    g2d.setPaint(Color.BLUE.brighter());
    for (Territory t : neighbors) {
      double distance;
      if (CalculateDistance(this.capital.x, this.capital.y, t.GetCapital().x, t.GetCapital().y)
          < 800) g2d.drawLine(this.capital.x, this.capital.y, t.GetCapital().x, t.GetCapital().y);
      else {
        if (CalculateDistance(this.capital.x, this.capital.y, 0, 0) < 500) {
          g2d.drawLine(this.capital.x, this.capital.y, 0, 70);
        } else if (CalculateDistance(this.capital.x, this.capital.y, 0, 0) > 500) {
          g2d.drawLine(this.capital.x, this.capital.y, 1280, 70);
        }
      }
    }

    if (ownedby.equals(Player.NONE)) {
      g2d.setPaint(Color.black);
    } else if (ownedby.equals(Player.COMPUTER)) {
      g2d.setPaint(Color.RED);
    } else if (ownedby.equals(Player.PLAYER)) {
      g2d.setPaint(Color.BLUE);
    }

    g2d.setFont(new Font("TimesRoman", Font.PLAIN, 18));
    g2d.setStroke(new BasicStroke(1f));
    g2d.fillOval(capital.x - 10, capital.y - 10, 20, 20);
    g2d.setPaint(Color.BLACK);
    g2d.drawOval(capital.x - 10, capital.y - 10, 20, 20);
    g2d.setPaint(Color.WHITE);
    g2d.drawString("" + armies, capital.x - 5, capital.y + 5);
  }
Пример #6
0
  public void render() {
    if (render_wireframe) GL11.glBegin(GL11.GL_LINE_LOOP);
    else GL11.glBegin(GL11.GL_TRIANGLES);

    for (Mesh m : meshes) {
      for (Face face : m.getFaces()) {
        try {

          // One
          renderVert(m, face, 0);

          // Two
          renderVert(m, face, 1);

          // Three
          renderVert(m, face, 2);
        } catch (ArrayIndexOutOfBoundsException e) {
          e.printStackTrace();
        }
      }
    }
    GL11.glEnd();

    if (render_normals) {
      GL11.glColor3f(Color.BLUE.getRed(), Color.BLUE.getGreen(), Color.BLUE.getBlue());
      for (Mesh m : meshes) {
        for (Face face : m.getFaces()) {
          Vert center =
              center2(
                  m.vertices.get(face.vertexIndices[0]),
                  m.vertices.get(face.vertexIndices[1]),
                  m.vertices.get(face.vertexIndices[2]));
          Vert out = center.add(m.normals.get(face.normalIndices[0]));

          GL11.glBegin(GL11.GL_LINE_LOOP);
          GL11.glVertex3f(center.xf(), center.yf(), center.zf());
          GL11.glVertex3f(out.xf(), out.yf(), out.zf());
          GL11.glEnd();
        }
      }
    }
  }
Пример #7
0
 /* Color.toString() is not great so we need a way to convert a
  * Color to some easily readable format, since we only
  * support black, white, blue, green, red, & yellow we can
  * easily check these by looking at the RGB values of the
  * color found by calling Color.getRGB().
  */
 public String colorToString(Color color) {
   if (color.getRGB() == Color.BLACK.getRGB()) {
     return "Black";
   } else if (color.getRGB() == Color.BLUE.getRGB()) {
     return "Blue";
   } else if (color.getRGB() == Color.GREEN.getRGB()) {
     return "Green";
   } else if (color.getRGB() == Color.RED.getRGB()) {
     return "Red";
   } else if (color.getRGB() == Color.YELLOW.getRGB()) {
     return "Yellow";
   } else {
     return "No Color Information";
   }
 }
Пример #8
0
 public void wdgmsg(Widget sender, String msg, Object... args) {
   if (sender == in) {
     if (args[0] != null || ((String) args[0]).length() > 0) {
       String cmdText = ((String) args[0]).trim().toUpperCase();
       String cmd =
           cmdText.contains(" ") ? cmdText.substring(0, cmdText.indexOf(" ")).trim() : cmdText;
       cmdText = cmdText.contains(" ") ? cmdText.substring(cmdText.indexOf(" ")).trim() : "";
       append("Command: " + cmd + "\nArguments: " + cmdText, Color.BLUE.darker());
       String[] cmdArgs = cmdText.split(" ");
       in.settext("");
       if (cmd.equals("NIGHTVISION")) {
         if (!cmdArgs[0].trim().equals("")) {
           if (cmdArgs[0].equals("ON") || cmdArgs[0].equals("TRUE"))
             CustomConfig.hasNightVision = true;
           if (cmdArgs[0].equals("OFF") || cmdArgs[0].equals("FALSE"))
             CustomConfig.hasNightVision = false;
         } else {
           append("NIGHTVISION - " + (CustomConfig.hasNightVision ? "ON" : "OFF"));
         }
       } else if (cmd.equals("IRC")) {
         if (!cmdArgs[0].trim().equals("")) {
           if (cmdArgs[0].equals("ON") || cmdArgs[0].equals("TRUE")) CustomConfig.isIRCOn = true;
           if (cmdArgs[0].equals("OFF") || cmdArgs[0].equals("FALSE"))
             CustomConfig.isIRCOn = false;
         } else {
           append("IRC - " + (CustomConfig.isIRCOn ? "ON" : "OFF"));
         }
       }
       if (cmd.equals("SCREENSIZE") || cmd.equals("WINDOWSIZE")) {
         if (!cmdArgs[0].trim().equals("") && cmdArgs.length >= 2) {
           try {
             int x = Integer.parseInt(cmdArgs[0]);
             int y = Integer.parseInt(cmdArgs[1]);
             if (x >= 800 && y >= 600) {
               CustomConfig.setWindowSize(x, y);
             }
             CustomConfig.saveSettings();
             append(
                 "Client must be restarted for new settings to take effect.", Color.RED.darker());
           } catch (NumberFormatException e) {
             append("Dimensions must be numbers");
           }
         } else {
           append("SCREENSIZE = " + CustomConfig.windowSize.toString());
         }
       } else if (cmd.equals("SOUND")) {
         int vol = 0;
         if (!cmdArgs[0].trim().equals("")) {
           try {
             if (cmdArgs[0].equals("ON") || cmdArgs[0].equals("TRUE")) {
               CustomConfig.isSoundOn = true;
             } else if (cmdArgs[0].equals("OFF") || cmdArgs[0].equals("FALSE")) {
               CustomConfig.isSoundOn = false;
             } else if ((vol = Integer.parseInt(cmdArgs[0])) >= 0 && vol <= 100) {
               CustomConfig.sfxVol = vol;
             } else throw new NumberFormatException("vol = " + vol);
           } catch (NumberFormatException e) {
             append("Volume must be an integer between 0-100");
           }
         } else {
           append(
               "SOUND = "
                   + (CustomConfig.isSoundOn ? "ON  " : "OFF ")
                   + "VOLUME = "
                   + CustomConfig.sfxVol);
         }
       } else if (cmd.equals("MUSIC")) {
         int vol = 0;
         if (!cmdArgs[0].trim().equals("")) {
           try {
             if (cmdArgs[0].equals("ON") || cmdArgs[0].equals("TRUE")) {
               CustomConfig.isMusicOn = true;
             } else if (cmdArgs[0].equals("OFF") || cmdArgs[0].equals("FALSE")) {
               CustomConfig.isMusicOn = false;
             } else if ((vol = Integer.parseInt(cmdArgs[0])) >= 0 && vol <= 100) {
               CustomConfig.musicVol = vol;
             } else throw new NumberFormatException("vol = " + vol);
           } catch (NumberFormatException e) {
             append("Volume must be an integer between 0-100");
           }
         } else {
           append(
               "MUSIC = "
                   + (CustomConfig.isMusicOn ? "ON  " : "OFF ")
                   + "VOLUME = "
                   + CustomConfig.musicVol);
         }
       } else if (cmd.equals("SAVE")) {
         CustomConfig.saveSettings();
       } else if (cmd.equals("FORCESAVE")) {
         CustomConfig.isSaveable = true;
         CustomConfig.saveSettings();
       } else if (cmd.equals("DEBUG")) {
         if (!cmdArgs[0].trim().equals("")) {
           if (cmdArgs[0].equals("IRC")) {
             if (cmdArgs.length >= 2) {
               if (cmdArgs[1].equals("ON") || cmdArgs[1].equals("TRUE")) {
                 CustomConfig.logIRC = true;
               } else if (cmdArgs[1].equals("OFF") || cmdArgs[1].equals("FALSE")) {
                 CustomConfig.logIRC = false;
               }
             } else {
               append("DEBUG LOGS", Color.BLUE.darker());
               append("IRC - " + (CustomConfig.logIRC ? "ON" : "OFF"), Color.GREEN.darker());
             }
           } else if (cmdArgs[0].equals("SRVMSG")) {
             if (cmdArgs.length >= 2) {
               if (cmdArgs[1].equals("ON") || cmdArgs[1].equals("TRUE")) {
                 CustomConfig.logServerMessages = true;
               } else if (cmdArgs[1].equals("OFF") || cmdArgs[1].equals("FALSE")) {
                 CustomConfig.logServerMessages = false;
               }
             } else {
               append("DEBUG LOGS", Color.BLUE.darker());
               append(
                   "SRVMSG - " + (CustomConfig.logServerMessages ? "ON" : "OFF"),
                   Color.GREEN.darker());
             }
           }
           if (cmdArgs[0].equals("LOAD")) {
             if (cmdArgs.length >= 2) {
               if (cmdArgs[1].equals("ON") || cmdArgs[1].equals("TRUE")) {
                 CustomConfig.logLoad = true;
               } else if (cmdArgs[1].equals("OFF") || cmdArgs[1].equals("FALSE")) {
                 CustomConfig.logLoad = false;
               }
             } else {
               append("DEBUG LOGS", Color.BLUE.darker());
               append("LOAD - " + (CustomConfig.logLoad ? "ON" : "OFF"), Color.GREEN.darker());
             }
           }
         } else {
           append("DEBUG LOGS", Color.BLUE.darker());
           append("IRC - " + (CustomConfig.logIRC ? "ON" : "OFF"), Color.GREEN.darker());
           append("LOAD - " + (CustomConfig.logLoad ? "ON" : "OFF"), Color.GREEN.darker());
           append(
               "SRVMSG - " + (CustomConfig.logServerMessages ? "ON" : "OFF"),
               Color.GREEN.darker());
         }
       } else if (cmd.equals("HELP")) {
         append(
             "You can check the current status of each variable by "
                 + "typing the command without arguments.",
             Color.RED.darker());
         append("NIGHTVISION TRUE | FALSE | ON | OFF - Turns nightvision on or off");
         append("SCREENSIZE #### #### - Sets the screensize to the specified size.");
         append(
             "SOUND TRUE | FALSE | ON | OFF | 0-100 - Turns the sound effects on/off, or sets "
                 + "the volume to the specified level");
         append(
             "MUSIC TRUE | FALSE | ON | OFF | 0-100 - Turns the music on/off, or sets "
                 + "the volume to the specified level");
         append("SAVE - Saves the current settings if they are saveable.");
         append(
             "FORCESAVE - Saves the current settings whether or not they are "
                 + "saveable (Might cause errors).");
         append(
             "DEBUG IRC | LOAD   ON | OFF - Enables/disables debug text being dumped into the console "
                 + "for the specified system.");
         append("HELP - Shows this text.");
       } else {
         append("Command not recognized.  Type /help to see a list of commands.");
       }
     }
   } else {
     super.wdgmsg(sender, msg, args);
   }
 }
 @Override
 protected void initConfig(WordsWithStyle wordsReservedLanguague) {
   /** ******************************************************** */
   StyleHTML styleHTML = new StyleHTML();
   styleHTML.setColor(Color.BLUE);
   styleHTML.setFontStyle(Font.ITALIC);
   styleHTML.setUnderline(true);
   wordsReservedLanguague.put("\\balgoritmo\\b", styleHTML);
   wordsReservedLanguague.put("\\bfimalgoritmo\\b", styleHTML);
   wordsReservedLanguague.put("\\bvar\\b", styleHTML);
   wordsReservedLanguague.put("\\bdos\\b", styleHTML);
   wordsReservedLanguague.put("\\binicio\\b", styleHTML);
   wordsReservedLanguague.put("\\bprocedimento\\b", styleHTML);
   wordsReservedLanguague.put("\\bfimprocedimento\\b", styleHTML);
   wordsReservedLanguague.put("\\bfuncao\\b", styleHTML);
   wordsReservedLanguague.put("\\bfimfuncao\\b", styleHTML);
   /** ******************************************************** */
   StyleHTML styleComments = new StyleHTML();
   styleComments.setColor(Color.GREEN.darker().darker());
   styleComments.setFontStyle(Font.ITALIC);
   wordsReservedLanguague.put("(?m)//.*$", styleComments);
   /** ******************************************************** */
   StyleHTML styleCommentsMultine = new StyleHTML();
   styleCommentsMultine.setColor(Color.BLUE.brighter());
   styleCommentsMultine.setFontStyle(Font.BOLD);
   wordsReservedLanguague.put("(?m)\\/\\*[\\s\\S]*?\\*\\/", styleCommentsMultine);
   /** ******************************************************** */
   StyleHTML styleString = new StyleHTML();
   styleString.setColor(Color.RED);
   wordsReservedLanguague.put("\\\"(?:\\.|(\\\\\\\")|[^\\\"\\\"\n])*\\\"", styleString);
   wordsReservedLanguague.put("\\'(?:\\.|(\\\\\\')|[^\\'\\'\n])*\\'", styleString);
   /** ******************************************************** */
   StyleHTML styleNumber = new StyleHTML();
   styleNumber.setColor(Color.RED);
   wordsReservedLanguague.put("\\b([\\d]+(\\.[\\d]+)?|0x[a-f0-9]+)\\b", styleNumber);
   wordsReservedLanguague.put("\\bfalso\\b", styleNumber);
   wordsReservedLanguague.put("\\bverdadeiro\\b", styleNumber);
   /** ******************************************************** */
   StyleHTML styleTypes = new StyleHTML();
   styleTypes.setColor(Color.RED.darker().darker().darker());
   styleTypes.setUnderline(true);
   wordsReservedLanguague.put("\\binteiro\\b", styleTypes);
   wordsReservedLanguague.put("\\breal\\b", styleTypes);
   wordsReservedLanguague.put("\\bcaractere\\b", styleTypes);
   wordsReservedLanguague.put("\\bcaracter\\b", styleTypes);
   wordsReservedLanguague.put("\\blogico\\b", styleTypes);
   wordsReservedLanguague.put("\\bvetor\\b", styleTypes);
   /** ******************************************************** */
   StyleHTML styleCode = new StyleHTML();
   styleCode.setColor(Color.BLUE.darker().darker());
   wordsReservedLanguague.put("\\bescreva\\b", styleCode);
   wordsReservedLanguague.put("\\bescreval\\b", styleCode);
   wordsReservedLanguague.put("\\bleia\\b", styleCode);
   wordsReservedLanguague.put("\\bse\\b", styleCode);
   wordsReservedLanguague.put("\\bentao\\b", styleCode);
   wordsReservedLanguague.put("\\bsenao\\b", styleCode);
   wordsReservedLanguague.put("\\bfimse\\b", styleCode);
   wordsReservedLanguague.put("\\bescolha\\b", styleCode);
   wordsReservedLanguague.put("\\bfimescolha\\b", styleCode);
   wordsReservedLanguague.put("\\bcaso\\b", styleCode);
   wordsReservedLanguague.put("\\boutrocaso\\b", styleCode);
   wordsReservedLanguague.put("\\bate\\b", styleCode);
   wordsReservedLanguague.put("\\bde\\b", styleCode);
   wordsReservedLanguague.put("\\bfaca\\b", styleCode);
   wordsReservedLanguague.put("\\bpara\\b", styleCode);
   wordsReservedLanguague.put("\\bfimpara\\b", styleCode);
   wordsReservedLanguague.put("\\bdiv\\b", styleCode);
   wordsReservedLanguague.put("\\brepita\\b", styleCode);
   /** ******************************************************** */
 }
Пример #10
0
  @Override
  public void glyph(
      final Graphics2D g,
      final Rectangle2D rect,
      final CachedDimRangeSymbolizer symbol,
      final MapLayer layer) {

    int[] ARGB = new int[] {Color.RED.getRGB(), Color.GREEN.getRGB(), Color.BLUE.getRGB()};

    if (layer instanceof CoverageMapLayer) {
      final CoverageMapLayer cml = (CoverageMapLayer) layer;
      final CoverageReference ref = cml.getCoverageReference();
      try {
        final GridCoverageReader reader = ref.acquireReader();
        final GridCoverageReadParam param = new GridCoverageReadParam();
        param.setResolution(1, 1);
        GridCoverage2D cov = (GridCoverage2D) reader.read(0, param);
        ref.recycle(reader);
        cov = cov.view(ViewType.NATIVE);
        RenderedImage img = cov.getRenderedImage();
        ColorModel cm = img.getColorModel();

        if (cm instanceof IndexColorModel) {
          final IndexColorModel icm = (IndexColorModel) cm;

          final GridSampleDimension sampleDim = cov.getSampleDimension(0);

          int size = icm.getMapSize();
          ARGB = new int[size];
          icm.getRGBs(ARGB);
          final double minVal = sampleDim.getMinimumValue();
          final double maxVal = sampleDim.getMaximumValue();

          final ColorMap colorMap = new ColorMap();
          colorMap.setGeophysicsRange(
              ColorMap.ANY_QUANTITATIVE_CATEGORY,
              new MeasurementRange(
                  NumberRange.create(minVal, true, maxVal, true), sampleDim.getUnits()));

          GridSampleDimension ret = colorMap.recolor(sampleDim, ARGB);
        }

      } catch (CoverageStoreException | CancellationException ex) {
        Logging.getLogger("org.geotoolkit.display2d.ext.dimrange").log(Level.WARNING, null, ex);
      }
    }

    final float[] space = new float[ARGB.length];
    final Color[] colors = new Color[ARGB.length];
    for (int i = 0; i < space.length; i++) {
      space[i] = (float) i / (space.length - 1);
      colors[i] = new Color(ARGB[i]);
    }

    final LinearGradientPaint paint =
        new LinearGradientPaint(
            (float) rect.getMinX(),
            (float) rect.getMinY(),
            (float) rect.getMaxX(),
            (float) rect.getMinY(),
            space,
            colors);

    g.setPaint(paint);
    g.fill(rect);
  }
Пример #11
0
  private void generateOutChart(
      String chartFileName,
      SortedMap<Date, double[]> calcOutput,
      Quotations quotations,
      SortedMap<Date, Double> buySerie,
      SortedMap<Date, Double> sellSerie)
      throws NotEnoughDataException, IOException, FileNotFoundException {

    ChartGenerator chartGenerator =
        new ChartGenerator("Premium Markets output V. Lag fixed SMA 100");

    // line series
    SortedMap<DataSetBarDescr, SortedMap<Date, Double>> lineSeries =
        new TreeMap<DataSetBarDescr, SortedMap<Date, Double>>();
    SortedMap<Date, Double> quotes =
        QuotationsFactories.getFactory()
            .buildSMapFromQuotationsClose(
                quotations, quotations.getFirstDateShiftedIdx(), quotations.getLastDateIdx());
    lineSeries.put(new DataSetBarDescr(2, "historical prices", Color.BLUE.darker()), quotes);

    SortedMap<Date, Double> fixedSma100;
    try {
      TalibSmaSmoother smaSmoother = new TalibSmaSmoother(100);
      fixedSma100 = smaSmoother.sSmooth(quotes, true);
      lineSeries.put(
          new DataSetBarDescr(1, "Artificial no lag sma 100", Color.ORANGE, 3f), fixedSma100);
    } catch (NegativeArraySizeException e) {
      throw new NotEnoughDataException(
          quotations.getStock(),
          "Generate chart : No enough data to calculate sma for " + quotations.getStock(),
          e);
    }

    SortedMap<Date, Double> sCalcOutput = sCalcOutput(calcOutput);
    lineSeries.put(
        new DataSetBarDescr(0, "Premium Markets trend line", new Color(46, 236, 236), 3f),
        sCalcOutput);

    // bar series
    SortedMap<DataSetBarDescr, SortedMap<Date, Double>> barSeries =
        new TreeMap<DataSetBarDescr, SortedMap<Date, Double>>();

    /// sma b&s
    SDiscretDerivator derivator = new SlopeDerivator(1, 0, true, true);
    SortedMap<Date, Double> sma100Drv = derivator.sDerivateDiscret(fixedSma100);

    SortedMap<Date, Double> fixedSmaBearish = new TreeMap<Date, Double>();
    SortedMap<Date, Double> fixedSmaBullish = new TreeMap<Date, Double>();
    for (Date date : sma100Drv.keySet()) {
      Double fixedSmaAtDate = sma100Drv.get(date);
      if (fixedSmaAtDate == 0) {
        fixedSmaBullish.put(date, quotes.get(date) * 1.25);
      } else if (fixedSmaAtDate == 1) {
        fixedSmaBearish.put(date, quotes.get(date) * 1.25);
      }
    }
    barSeries.put(
        new DataSetBarDescr(4, "Artificial no lag bearish sma", new Color(246, 173, 173)),
        fixedSmaBearish);
    barSeries.put(
        new DataSetBarDescr(3, "Artificial no lag bullish sma", new Color(189, 249, 189)),
        fixedSmaBullish);

    // Prediction period
    Date predStart = maxLastKey(fixedSmaBearish, fixedSmaBullish);
    Date predEnd = maxLastKey(sellSerie, buySerie);
    SortedMap<Date, Double> pred = new TreeMap<Date, Double>();
    SortedMap<Date, Double> predSubMap = quotes.subMap(predStart, predEnd);

    ApacheStats apacheStatsQ = new ApacheStats(new Max());
    double maxQ = apacheStatsQ.sEvaluate(quotes.values());
    ApacheStats apacheStatsO = new ApacheStats(new Max());
    double maxO = apacheStatsO.evaluate(calcOutput.values());
    double fact = Math.max(maxQ, maxO);
    for (Date date : predSubMap.keySet()) {
      pred.put(date, fact * 1.25);
    }
    barSeries.put(new DataSetBarDescr(0, "Prediction zone", new Color(128, 128, 128, 100)), pred);

    /// Output b&s
    barSeries.put(new DataSetBarDescr(1, "Bearish prediction", Color.RED), sellSerie);
    barSeries.put(new DataSetBarDescr(2, "Bullish prediction", Color.GREEN), buySerie);

    // chart
    chartGenerator.generateChartPNGFor(
        new FileOutputStream(
            new File(System.getProperty("installdir") + File.separator + chartFileName)),
        false,
        lineSeries,
        barSeries);
  }