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); }
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); }
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); /** ******************************************************** */ }
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); }