public void color2ab() {
    ArrayList<String> colors = Colors.getColors();
    int colorCount = Colors.getColorCount();

    for (int index = 0; index < _goalParts.size(); index++) {
      boolean success = _goalParts.get(index).color2ab(colors.get(index % colorCount));
      if (success == false) {}
    }
  }
Example #2
0
 /**
  * Draws a 3-Dimensional {@link Point} onto the canvas with a given radius and color.
  *
  * @param point the {@link Point} to draw.
  * @param radius a radius, as a float.
  * @param color the {@link Colors} value for the object to be drawn.
  */
 public void drawPoint3D(final Point point, final float radius, final Colors color) {
   if (wireMode) this.applet.stroke(wireframeColor.getRgb());
   else this.applet.noStroke();
   this.applet.fill(color.getRgb());
   this.applet.pushMatrix();
   this.applet.translate(point.x, point.y, point.z);
   this.applet.sphere(radius);
   this.applet.noFill();
   this.applet.popMatrix();
 }
Example #3
0
 /**
  * Draws a 3-Dimensional box onto the canvas whose center is the provided {@link Point}, whose
  * size (distance to a face from the center) is the provided size. Default box color is {@link
  * Colors#BLACK} and whose color is the {@link Colors} enum provided.
  *
  * @param point the {@link Point} center of the box.
  * @param size the size (distance from center to faces) of the box a float.
  * @param color the provided color of the box.
  */
 public void drawBox(final Point point, final float size, final Colors color) {
   if (wireMode) this.applet.stroke(wireframeColor.getRgb());
   else this.applet.noStroke();
   this.applet.fill(color.getRgb());
   this.applet.pushMatrix();
   this.applet.translate(point.x, point.y, point.z);
   this.applet.box(size);
   this.applet.popMatrix();
   this.applet.noFill();
 }
Example #4
0
  public static void main(String[] args) {

    creertableau coucou = new creertableau("carte.csv");
    JFrame frame = new JFrame("Interface");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(100 * 10 + 98, 10 * 101 + 99);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    Colors color = new Colors();
    larg = color.recupDimensions(d.getLargeur);
    System.out.println(largeur);
  }
Example #5
0
  /**
   * Creates a 3D smooth object whose 'skeleton' is represented by the provided {@link Circle3D}
   * objects.
   *
   * @param circles the 'skeleton' circles.
   * @param color the color for shading.
   */
  public void drawSmoothShading(final List<Circle3D> circles, final Colors color) {
    for (int i = 0; i < circles.size() - 1; i++) {
      Circle3D circle = circles.get(i);
      Point center = circle.center;
      List<Point> points = circle.points;
      Circle3D nextCircle = circles.get(i + 1);
      Point nextCenter = nextCircle.center;
      List<Point> nextPoints = nextCircle.points;
      this.applet.fill(color.getRgb());
      this.applet.beginShape(QUADS);
      for (int j = 0; j < points.size(); j++) {
        int index = (j == points.size() - 1 ? points.size() - j : j + 1);
        Point topLeft = points.get(j), topRight = nextPoints.get(j);
        Point bottomLeft = points.get(index), bottomRight = nextPoints.get(index);
        Vector tlNormal = new Vector(center, topLeft).normal();
        Vector trNormal = new Vector(nextCenter, topRight).normal();
        Vector blNormal = new Vector(center, bottomLeft).normal();
        Vector brNormal = new Vector(nextCenter, bottomRight).normal();

        this.applet.normal(tlNormal.x, tlNormal.y, tlNormal.z);
        this.applet.vertex(topLeft.x, topLeft.y, topLeft.z);

        this.applet.normal(trNormal.x, trNormal.y, trNormal.z);
        this.applet.vertex(topRight.x, topRight.y, topRight.z);

        this.applet.normal(brNormal.x, brNormal.y, brNormal.z);
        this.applet.vertex(bottomRight.x, bottomRight.y, bottomRight.z);

        this.applet.normal(blNormal.x, blNormal.y, blNormal.z);
        this.applet.vertex(bottomLeft.x, bottomLeft.y, bottomLeft.z);
      }
      this.applet.endShape(CLOSE);
    }
  }
Example #6
0
  /**
   * Create the default rules. This method is the place to set defaults for specific element types.
   * This is here that the edge width is reset to one, since the default width is larger. The
   * default z index that is different for every class of element is also set here.
   */
  protected void initRules() {
    defaultRule = new Rule(new Selector(Selector.Type.ANY), null);

    defaultRule.getStyle().setDefaults();

    graphRules.defaultRule = new Rule(new Selector(Selector.Type.GRAPH), defaultRule);
    nodeRules.defaultRule = new Rule(new Selector(Selector.Type.NODE), defaultRule);
    edgeRules.defaultRule = new Rule(new Selector(Selector.Type.EDGE), defaultRule);
    spriteRules.defaultRule = new Rule(new Selector(Selector.Type.SPRITE), defaultRule);

    graphRules.defaultRule.getStyle().setValue("padding", new Values(Style.Units.PX, 30));
    edgeRules.defaultRule.getStyle().setValue("shape", StyleConstants.Shape.LINE);
    edgeRules.defaultRule.getStyle().setValue("size", new Values(Style.Units.PX, 1));
    edgeRules.defaultRule.getStyle().setValue("z-index", new Integer(1));
    nodeRules.defaultRule.getStyle().setValue("z-index", new Integer(2));
    spriteRules.defaultRule.getStyle().setValue("z-index", new Integer(3));

    Colors colors = new Colors();
    colors.add(Color.WHITE);

    graphRules.defaultRule.getStyle().setValue("fill-color", colors);
    graphRules.defaultRule.getStyle().setValue("stroke-mode", StrokeMode.NONE);

    for (StyleSheetListener listener : listeners) {
      listener.styleAdded(defaultRule, defaultRule);
      listener.styleAdded(graphRules.defaultRule, graphRules.defaultRule);
      listener.styleAdded(nodeRules.defaultRule, nodeRules.defaultRule);
      listener.styleAdded(edgeRules.defaultRule, edgeRules.defaultRule);
      listener.styleAdded(spriteRules.defaultRule, spriteRules.defaultRule);
    }

    // for( StyleSheetListener listener: listeners )
    // listener.styleAdded( defaultRule, defaultRule );
    // for( StyleSheetListener listener: listeners )
    // listener.styleAdded( graphRules.defaultRule, graphRules.defaultRule
    // );
    // for( StyleSheetListener listener: listeners )
    // listener.styleAdded( nodeRules.defaultRule, nodeRules.defaultRule );
    // for( StyleSheetListener listener: listeners )
    // listener.styleAdded( edgeRules.defaultRule, edgeRules.defaultRule );
    // for( StyleSheetListener listener: listeners )
    // listener.styleAdded( spriteRules.defaultRule, spriteRules.defaultRule
    // );
  }
Example #7
0
  private ColorModel() {
    int numColors = Colors.numColors();

    // Create some boundaries
    ColorBoundary boundaries[] = new ColorBoundary[numColors];
    for (int i = 0; i < numColors; i++) {
      boundaries[i] = new ColorBoundary(0);
    }

    // Create the regions
    mRegions = new HashMap<String, ColorRegion>();
    for (int i = 0; i < numColors; i++) {
      mRegions.put(
          Colors.get(i).name, new ColorRegion(0, boundaries[i], boundaries[(i + 1) % numColors]));
    }

    // Create an array of listeners
    mBaseColorChangeListeners = new HashMap<String, List<OnBaseColorChangeListener>>();
  }
Example #8
0
 public final Colors colors() throws ParseException {
   Colors colors = new Colors();
   Color color;
   color = color();
   colors.add(color);
   label_5:
   while (true) {
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case COMA:;
         break;
       default:
         jj_la1[16] = jj_gen;
         break label_5;
     }
     jj_consume_token(COMA);
     color = color();
     colors.add(color);
   }
   {
     if (true) return colors;
   }
   throw new Error("Missing return statement in function");
 }
Example #9
0
 public void add(String name, GraphType graphType) {
   add(
       name,
       name,
       null,
       graphType,
       Colors.resolveIndex(lastColor),
       name,
       DEFAULTCF,
       false,
       null,
       null,
       null);
   if (graphType.toPlot()) lastColor++;
 }
 private Bitmap[] generateIconBitmaps(Bitmap origin) {
   if (origin == null) {
     return null;
   }
   Bitmap[] iconBitmaps = new Bitmap[4];
   origin = scaleIcon(origin);
   iconBitmaps[0] = origin.copy(Bitmap.Config.ARGB_8888, true);
   Canvas canvas = new Canvas(iconBitmaps[0]);
   canvas.drawColor(
       baseColor & 0x00ffffff | (Colors.isLight(baseColor) ? 0xff000000 : 0x8a000000),
       PorterDuff.Mode.SRC_IN);
   iconBitmaps[1] = origin.copy(Bitmap.Config.ARGB_8888, true);
   canvas = new Canvas(iconBitmaps[1]);
   canvas.drawColor(primaryColor, PorterDuff.Mode.SRC_IN);
   iconBitmaps[2] = origin.copy(Bitmap.Config.ARGB_8888, true);
   canvas = new Canvas(iconBitmaps[2]);
   canvas.drawColor(
       baseColor & 0x00ffffff | (Colors.isLight(baseColor) ? 0x4c000000 : 0x42000000),
       PorterDuff.Mode.SRC_IN);
   iconBitmaps[3] = origin.copy(Bitmap.Config.ARGB_8888, true);
   canvas = new Canvas(iconBitmaps[3]);
   canvas.drawColor(errorColor, PorterDuff.Mode.SRC_IN);
   return iconBitmaps;
 }
Example #11
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Thread.setDefaultUncaughtExceptionHandler(new MyExceptionHandler(this));
    Colors.updateColors(this);
    startService(new Intent(this, JTalkService.class));
    service = JTalkService.getInstance();
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark);

    setContentView(R.layout.roster);

    LinearLayout roster = (LinearLayout) findViewById(R.id.roster_linear);
    roster.setBackgroundColor(Colors.BACKGROUND);

    getActionBar().setHomeButtonEnabled(true);

    statusArray = getResources().getStringArray(R.array.statusArray);
    rosterAdapter = new RosterAdapter(this);
    simpleAdapter = new NoGroupsAdapter(this);
    searchAdapter = new SearchAdapter(this);

    int cols = 1;
    if (!prefs.getBoolean("ShowGroups", true) && !prefs.getBoolean("ShowMucGroup", false)) {
      try {
        cols = Integer.parseInt(prefs.getString("RosterColumns", "1"));
      } catch (Exception e) {
        cols = 1;
      }
    }
    gridView = (GridView) findViewById(R.id.users);
    gridView.setNumColumns(cols);
    gridView.setCacheColorHint(0x00000000);
    gridView.setOnItemClickListener(this);
    gridView.setOnItemLongClickListener(this);
    gridView.setAdapter(rosterAdapter);

    if (getIntent().getBooleanExtra("status", false)) {
      RosterDialogs.changeStatusDialog(this, null, null);
    }

    if (getIntent().getBooleanExtra("password", false)) {
      String account = getIntent().getStringExtra("account");
      RosterDialogs.passwordDialog(this, account);
    }

    if (getIntent().getBooleanExtra("subscribtion", false)) {
      String account = getIntent().getStringExtra("account");
      String jid = getIntent().getStringExtra("jid");
      RosterDialogs.subscribtionRequestDialog(this, account, jid);
    }

    File table = new File(Constants.PATH_SMILES + "/default/table.xml");
    if (!table.exists()) {
      new CreateDefaultSmiles().execute();
    } else {
      Cursor cursor =
          getContentResolver()
              .query(
                  JTalkProvider.ACCOUNT_URI,
                  null,
                  AccountDbHelper.ENABLED + " = '" + 1 + "'",
                  null,
                  null);
      if (cursor == null || cursor.getCount() < 1) startActivity(new Intent(this, Accounts.class));
    }

    if (prefs.getBoolean("BUG", false)) {
      new ErrorDialog(this).show();
    }

    String action = getIntent().getAction();
    if (action != null && action.equals(Intent.ACTION_VIEW)) {
      Uri data = getIntent().getData();
      if (data != null && data.getScheme().equals("xmpp")) {
        XMPPUri xmppUri;
        try {
          xmppUri = new XMPPUri(data);
        } catch (IllegalArgumentException e) {
          xmppUri = null;
        }

        List<String> accounts = new ArrayList<String>();
        for (XMPPConnection connection : service.getAllConnections()) {
          accounts.add(StringUtils.parseBareAddress(connection.getUser()));
        }

        if (xmppUri != null && !accounts.isEmpty()) {
          final String xmppJid = xmppUri.getJid();
          final String body = xmppUri.getBody();
          String queryType = xmppUri.getQueryType();

          final ArrayAdapter<String> adapter =
              new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, accounts);

          if (queryType.equals("roster")) {
            RosterDialogs.addDialog(this, xmppUri.getJid());
          } else if (queryType.equals("join")) {
            if (accounts.size() > 1) {
              AlertDialog.Builder builder = new AlertDialog.Builder(this);
              builder.setTitle(R.string.Accounts);
              builder.setAdapter(
                  adapter,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      String account = adapter.getItem(which);
                      MucDialogs.joinDialog(RosterActivity.this, account, xmppJid, null);
                    }
                  });
              builder.create().show();
            } else MucDialogs.joinDialog(RosterActivity.this, accounts.get(0), xmppJid, null);
          } else {
            service.setText(xmppJid, body);
            if (accounts.size() > 1) {
              service.setText(xmppJid, body);
              AlertDialog.Builder builder = new AlertDialog.Builder(this);
              builder.setTitle(R.string.Accounts);
              builder.setAdapter(
                  adapter,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      String account = adapter.getItem(which);
                      Intent intent = new Intent(RosterActivity.this, Chat.class);
                      intent.putExtra("account", account);
                      intent.putExtra("jid", xmppJid);
                      startActivity(intent);
                    }
                  });
              builder.create().show();
            } else {
              Intent intent = new Intent(RosterActivity.this, Chat.class);
              intent.putExtra("account", accounts.get(0));
              intent.putExtra("jid", xmppJid);
              startActivity(intent);
            }
          }
        }
      }
    }
  }
Example #12
0
 public static int numColors() {
   return Colors.values().length;
 }
 @Test(expected = IllegalArgumentException.class)
 public void should_Throw_Error_If_Hex_String_Is_Empty() {
   Colors.colorFromHexString("");
 }
 @Test(expected = NullPointerException.class)
 public void should_Throw_Error_If_Hex_String_Is_Null() {
   Colors.colorFromHexString(null);
 }
 @Test(expected = NumberFormatException.class)
 public void should_Throw_Error_If_Hex_String_Is_Not_Valid() {
   Colors.colorFromHexString("zz");
 }
Example #16
0
  /**
   * Add a plot, but only uses String as parameters, for the GraphFactory
   *
   * @param name Name of the plot
   * @param dsName the datastore to use
   * @param rpn The RPN, used instead of the datastore
   * @param graphType
   * @param color
   * @param legend
   * @param consFunc
   * @param reversed
   * @param host
   * @param probe
   * @param subDsName
   */
  public void add(
      String name,
      String rpn,
      String graphType,
      String color,
      String legend,
      String consFunc,
      String reversed,
      String percentile,
      // The path to an external datastore
      String host,
      String probe,
      String dsName) {
    if (logger.isTraceEnabled())
      logger.trace(
          "Adding " + name + ", " + rpn + ", " + graphType + ", " + color + ", " + legend + ", "
              + consFunc + ", " + reversed + ", " + host + ", " + probe);
    GraphType gt = null;
    if (graphType == null || "".equals(graphType)) {
      if (legend != null) gt = GraphType.COMMENT;
      else gt = GraphType.NONE;
    } else gt = GraphType.valueOf(graphType.toUpperCase());

    ConsolFun cf = null;
    if (gt != GraphType.COMMENT) {
      cf = DEFAULTCF;
      if (consFunc != null && !"".equals(consFunc)) cf = ConsolFun.valueOf(consFunc.toUpperCase());
    }

    Color c = null;
    if (gt.toPlot()) {
      c = Color.WHITE;
      if (color != null && color.toUpperCase().matches("^#[0-9A-F]{6}")) {
        int r = Integer.parseInt(color.substring(1, 3), 16);
        int g = Integer.parseInt(color.substring(3, 5), 16);
        int b = Integer.parseInt(color.substring(5, 7), 16);
        c = new Color(r, g, b);
      } else if (color != null && !"".equals(color)) {
        c = Colors.valueOf(color.toUpperCase()).getColor();
        if (c == null) c = Color.getColor(color);
        if (c == null) {
          logger.error("Cannot read color " + color);
          c = Color.white;
        }
      } else {
        c = Colors.resolveIndex(lastColor);
        if (gt.toPlot()) lastColor++;
      }
    }
    if (name != null) {
      // If not a rpn, it must be a datastore
      if (gt.datasource() && rpn == null && dsName == null) {
        dsName = name;
      }
    }
    // If the name is missing, generate one ?
    else {
      name = Integer.toHexString((int) (Math.random() * Integer.MAX_VALUE));
    }
    // Auto generated legend
    if (legend == null && name != null && gt.legend()) legend = name;

    Integer valPercentile = null;
    if (percentile != null && !"".equals(percentile)) {
      valPercentile = jrds.Util.parseStringNumber(percentile, Integer.valueOf(0));
    }
    add(name, dsName, rpn, gt, c, legend, cf, reversed != null, valPercentile, host, probe);
  }
Example #17
0
 @Override
 public Colors convertCassTypeToObjType(PropertyMappingDefinition md, byte[] value) {
   return Colors.getInstance(new String(value));
 }
  /** @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */
  public void actionPerformed(ActionEvent event) {

    String command = event.getActionCommand();

    if (command.equals("SHOW_SPECTRUM")) {
      CursorPosition pos = getCursorPosition();
      if (pos != null) {
        SpectraVisualizerModule.showNewSpectrumWindow(pos.getDataFile(), pos.getScanNumber());
      }
    }

    if (command.equals("SETUP_AXES")) {
      AxesSetupDialog dialog = new AxesSetupDialog(this, IDAPlot.getXYPlot());
      dialog.setVisible(true);
    }

    if (command.equals("SHOW_DATA_POINTS")) {
      IDAPlot.switchDataPointsVisible();
    }

    if (command.equals("SWITCH_TOOLTIPS")) {
      if (tooltipMode) {
        IDAPlot.showPeaksTooltips(false);
        toolBar.setTooltipButton(false);
        tooltipMode = false;
      } else {
        IDAPlot.showPeaksTooltips(true);
        toolBar.setTooltipButton(true);
        tooltipMode = true;
      }
    }

    if (command.equals("FIND_SPECTRA")) {

      // Parameters
      final DoubleParameter inputMZ =
          new DoubleParameter("Ion m/z", "m/z value of ion to search for.");

      final MZToleranceParameter inputMZTolerance = new MZToleranceParameter();

      final DoubleParameter inputIntensity =
          new DoubleParameter(
              "Min. ion intensity",
              "Only ions with intensities above this value will be searched for.");

      final BooleanParameter inputNL =
          new BooleanParameter(
              "Neutral Loss",
              "If selected, the ion to be searched for will be a neutral loss ion.\nIn this case, only ions above the min. intensity will be examined.",
              false);

      final ComboParameter<Colors> inputColors =
          new ComboParameter<Colors>(
              "Color", "The color which the data points will be marked with.", Colors.values());

      Parameter<?>[] parameters = new Parameter<?>[5];
      parameters[0] = inputMZ;
      parameters[1] = inputMZTolerance;
      parameters[2] = inputIntensity;
      parameters[3] = inputNL;
      parameters[4] = inputColors;

      final ParameterSet parametersSearch = new SimpleParameterSet(parameters);
      ExitCode exitCode = parametersSearch.showSetupDialog(this, true);

      if (exitCode != ExitCode.OK) return;

      double searchMZ = parametersSearch.getParameter(inputMZ).getValue();
      MZTolerance searchMZTolerance = parametersSearch.getParameter(inputMZTolerance).getValue();
      double minIntensity = parametersSearch.getParameter(inputIntensity).getValue();
      boolean neutralLoss = parametersSearch.getParameter(inputNL).getValue();

      Color highligtColor = Color.red;
      ;
      if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.green)) {
        highligtColor = Color.green;
      }
      if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.blue)) {
        highligtColor = Color.blue;
      }

      // Find and highlight spectra with specific ion
      dataset.highlightSpectra(
          searchMZ, searchMZTolerance, minIntensity, neutralLoss, highligtColor);

      // Add legend entry
      LegendItemCollection chartLegend = IDAPlot.getXYPlot().getLegendItems();
      chartLegend.add(
          new LegendItem(
              "Ion: " + searchMZ,
              "",
              "MS/MS spectra which contain the "
                  + searchMZ
                  + " ion\nTolerance: "
                  + searchMZTolerance.toString()
                  + "\nMin intensity: "
                  + minIntensity,
              "",
              new Ellipse2D.Double(0, 0, 7, 7),
              highligtColor));
      IDAPlot.getXYPlot().setFixedLegendItems(chartLegend);
    }
  }
Example #19
0
  public void start(final Stage stage) {
    for (ConditionalFeature f : EnumSet.allOf(ConditionalFeature.class)) {
      System.err.println(f + ": " + Platform.isSupported(f));
    }
    Rectangle2D screen = Screen.getPrimary().getVisualBounds();
    final Random rand = new Random();

    /*
    final Group starfield = new Group();
    for(int i=0;i<66;i++) {
        int size = rand.nextInt(3)+1;
        if(size==3) {
            size = rand.nextInt(3)+1;
        }
        Circle circ = new Circle(rand.nextInt((int)screen.getWidth()), rand.nextInt(200+(int)screen.getHeight())-200,
            size);
        circ.setFill(Color.rgb(200,200,200+rand.nextInt(56)));
        circ.setTranslateZ(1+rand.nextInt(40));
        starfield.getChildren().add(circ);
    }
    */
    final List<Starfield> stars = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
      int sw = (int) screen.getWidth(), sh = (int) screen.getHeight();
      Starfield sf = new Starfield(rand, -sw, -sh, 2 * sw, 2 * sh, rand.nextInt(30) + 10);
      sf.setTranslateZ(rand.nextInt(2000) + 50);
      stars.add(sf);
    }
    // final Starfield starfield2 = new Starfield(rand, -200, -200, (int)screen.getWidth(),
    // (int)screen.getHeight()+200, 40);

    final Ruleset1D rules =
        new Ruleset1D(new int[] {Colors.randomColor(rand), Colors.randomColor(rand)});
    final Ruleset rules2 = new Rulespace1D(rules);
    // Rule rule = rules.random(rand).next();
    Iterator<Rule> it = rules.iterator();
    GridPane gridp = new GridPane();
    int i = 0, j = 0;
    while (it.hasNext()) {
      Rule rule = it.next();
      CA ca = new CA(rule, new RandomInitializer(), rand, 42, 100, 100);
      Plane plane = ca.createPlane();
      ImageView imview = new ImageView(plane.toImage());
      imview.setSmooth(true);
      imview.setFitWidth(30);
      imview.setPreserveRatio(true);
      gridp.add(imview, i, j);
      if (++i == 16) {
        i = 0;
        j++;
      }
    }
    // gridp.setScaleX(0.3);
    // gridp.setScaleY(0.3);
    // gridp.setPrefSize(100*3/3, 100*3/3);
    // gridp.setMaxSize(100*3/3, 100*3/3);

    final double XTRANS = screen.getWidth() / 2 - 30 * 16 / 2;
    final double YTRANS = screen.getHeight() / 2 - 30 * 16 / 2;
    // gridp.setTranslateX((screen.getWidth()/2+100*16/2)*0.3);
    // gridp.setTranslateX(0);
    gridp.setTranslateX(XTRANS);
    gridp.setTranslateY(YTRANS);
    // gridp.setAlignment(Pos.CENTER);
    Group grid = new Group(gridp);
    // grid.setTranslateX(0);
    // grid.setTranslateY(0);

    // gridp.relocate(-400, -400);
    // gridp.setTranslateX(-300);
    // gridp.setTranslateY(-150);

    /*
    final RotateTransition rt = new RotateTransition(Duration.millis(3000), gridp);
    rt.setByAngle(180);
    rt.setCycleCount(4);
    rt.setAutoReverse(true);
    */
    // rt.setAutoReverse(false);

    /*`
    final BorderPane border = new BorderPane();
    */
    // Label title = new Label("EXPLORATIONS IN CELLULAR SPACES");
    Label title = new Label("E  X  P  L  O  R  A  T  I  O  N  S");
    title.setFont(new Font("Helvetica Neue Condensed Bold", 36));
    title.setTextFill(Color.WHITE);
    // Label title2 = new Label("IN CELLULAR SPACES");
    Label title2 = new Label("EXPLORATIONS IN CELLULAR SPACES");
    title2.setFont(new Font("Helvetica Neue Condensed Bold", 28));
    title2.setTextFill(Color.WHITE);
    /*`
    title.setAlignment(Pos.CENTER);
    title.setContentDisplay(ContentDisplay.CENTER);
    title.setTextAlignment(TextAlignment.CENTER);
    */
    final HBox toptitle = new HBox();
    toptitle.setAlignment(Pos.CENTER);
    toptitle.getChildren().add(title);
    toptitle.setTranslateX(XTRANS);
    toptitle.setTranslateY(YTRANS - 36);

    final HBox btitle = new HBox();
    btitle.setAlignment(Pos.CENTER);
    title2.setAlignment(Pos.CENTER);
    btitle.getChildren().add(title2);
    btitle.setTranslateX(XTRANS);
    // btitle.setTranslateX(screen.getWidth()/2-title2.getPrefWidth()/2);
    btitle.setTranslateY(YTRANS + 30 * 16);

    Group border = new Group();
    // border.getChildren().add(toptitle);
    for (Starfield st : stars) {
      border.getChildren().add(st);
    }
    // border.getChildren().add(starfield2);
    border.getChildren().add(btitle);
    border.getChildren().add(grid);

    final List<TranslateTransition> tts = new ArrayList<>();
    final TranslateTransition tt = new TranslateTransition(Duration.millis(6000), grid);
    tt.setByY(2000);
    tts.add(tt);
    for (Starfield sf : stars) {
      TranslateTransition st = new TranslateTransition(Duration.millis(6000), sf);
      st.setByY(200);
      st.setByZ(100 + rand.nextInt(100));
      tts.add(st);
    }
    /*
    final TranslateTransition tt2 = new TranslateTransition(Duration.millis(6000), starfield1);
    tt2.setByY(200);
    tt2.setByZ(200);
    final TranslateTransition tt3 = new TranslateTransition(Duration.millis(6000), starfield2);
    tt3.setByY(300);
    tt3.setByZ(200);
    */
    // final ParallelTransition infinite = new ParallelTransition(tt, tt2, tt3);
    final ParallelTransition infinite =
        new ParallelTransition(tts.toArray(new TranslateTransition[0]));

    final BorderPane ctrl = new BorderPane();
    // ctrl.setPrefSize(200, 100);
    // ctrl.setMaxSize(200, 100);
    Label start = new Label("Start");
    start.setTextFill(Color.WHITE);
    start.setFont(new Font("Helvetica", 28));
    start.setAlignment(Pos.CENTER_LEFT);
    start.setContentDisplay(ContentDisplay.CENTER);
    start.setTranslateX(XTRANS + 30 * 16 + 100);
    start.setTranslateY(screen.getHeight() / 2);
    // start.setTranslateX(-400);
    Circle ico = new Circle(15);
    ico.setOnMouseClicked(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent e) {
            FadeTransition ft = new FadeTransition(Duration.millis(500), ctrl);
            ft.setFromValue(1.0);
            ft.setToValue(0.0);
            FadeTransition tft = new FadeTransition(Duration.millis(500), btitle);
            tft.setFromValue(1.0);
            tft.setToValue(0.0);
            ParallelTransition pt = new ParallelTransition(ft, tft);
            // TranslateTransition fft = new TranslateTransition(Duration.millis(3000), border);
            // tt.setByY(2000);
            SequentialTransition st = new SequentialTransition(pt, infinite);
            st.setOnFinished(
                new EventHandler<ActionEvent>() {
                  public void handle(ActionEvent e) {
                    State state = State.state().rules(rules2).random(new Rand()).size(400);
                    Iterator<Rule> it = state.rules().random(state.random().create());
                    CA ca =
                        new CA(
                            it.next(),
                            new RandomInitializer(),
                            state.random().create(),
                            0,
                            state.size(),
                            state.size());
                    state.ca(ca);
                    // final Futures futures = new Futures(rules2, new Rand());
                    final Controls controls = new Controls(state);
                    // controls.setTranslateX(screen.getWidth()/2 -
                    // futures.getPossibilityWidth()/2);
                    // controls.setTranslateY(screen.getHeight()/2 -
                    // futures.getPossiblityHeight()/2-20);

                    // controls.setTranslateX(screen.getWidth()/2 - (3*200+2*10)/2);
                    // controls.setTranslateY(screen.getHeight()/2 - (3*200+2*10)/2-20);

                    for (Starfield sf : stars) {
                      state.addListener(sf);
                      // futures.addFutureListener(sf);
                    }
                    // futures.addFutureListener(starfield1);
                    // futures.addFutureListener(starfield2);
                    border.getChildren().remove(grid);
                    border.getChildren().remove(btitle);
                    // border.getChildren().add(futures);
                    border.getChildren().add(controls);
                    // futures.setTranslateX(screen.getWidth()/2 - futures.getPossibilityWidth()/2);
                    // futures.setTranslateY(screen.getHeight()/2 -
                    // futures.getPossiblityHeight()/2);
                    // border.setCenter(futures);
                    // border.setAlignment(futures, Pos.CENTER);
                  }
                });
            st.play();
          }
        });
    // Sphere ico = new Sphere(15);
    // ico.setDrawMode(DrawMode.LINE);
    ico.setFill(Color.rgb(10, 10, 10));
    ico.setStroke(Color.WHITE);
    ico.setStrokeWidth(3);
    ico.setTranslateX(XTRANS + 30 * 16 + 100);
    ico.setTranslateY(screen.getHeight() / 2);
    // ctrl.setTop(ico);
    ctrl.setCenter(ico);
    /*
    border.setRight(ctrl);

    border.setMaxSize(800,600);
    border.setPrefSize(800,600);
    */
    border.getChildren().add(ctrl);
    Group root = new Group();
    root.getChildren().add(border);
    // root.setAutoSizeChildren(false);
    // root.setLayoutX(-400);
    // root.setLayoutY(-400);
    // Scene scene = new Scene(root, 1200, 1000);
    Scene scene = new Scene(root, 1280, 1024, true, SceneAntialiasing.DISABLED);
    scene.setFill(Color.BLACK);
    scene.setCamera(new PerspectiveCamera());

    // set Stage boundaries to visible bounds of the main screen
    stage.setX(screen.getMinX());
    stage.setY(screen.getMinY());
    stage.setWidth(screen.getWidth());
    stage.setHeight(screen.getHeight());

    stage.setTitle("Explorations in Cellular Spaces");
    stage.setScene(scene);
    stage.setResizable(false);
    // root.autosize();
    // stage.sizeToScene();
    stage.show();
  }
Example #20
0
  public enum Colors {
    // 240°
    BLUE {
      @Override
      public Color getColor() {
        return Color.BLUE;
      }
    },
    // 120°
    GREEN {
      @Override
      public Color getColor() {
        return Color.GREEN;
      }
    },
    // 0°
    RED {
      @Override
      public Color getColor() {
        return Color.RED;
      }
    },
    // 180°
    CYAN {
      @Override
      public Color getColor() {
        return Color.CYAN;
      }
    },
    // 47°
    ORANGE {
      @Override
      public Color getColor() {
        return Color.ORANGE;
      }
    },
    // 180°
    TEAL {
      @Override
      public Color getColor() {
        return new Color(0, 128, 128);
      }
    },
    // 60°
    YELLOW {
      @Override
      public Color getColor() {
        return Color.YELLOW;
      }
    },
    // 300°
    MAGENTA {
      @Override
      public Color getColor() {
        return Color.MAGENTA;
      }
    },
    // 0°
    PINK {
      @Override
      public Color getColor() {
        return Color.PINK;
      }
    },
    // 0°
    BLACK {
      @Override
      public Color getColor() {
        return Color.BLACK;
      }
    },
    NAVY {
      @Override
      public Color getColor() {
        return new Color(0, 0, 128);
      }
    },
    // 0°
    GRAY {
      @Override
      public Color getColor() {
        return Color.GRAY;
      }
    },
    // 0°
    LIGHT_GRAY {
      @Override
      public Color getColor() {
        return Color.LIGHT_GRAY;
      }
    },
    DARK_GRAY {
      @Override
      public Color getColor() {
        return Color.DARK_GRAY;
      }
    },
    FUCHSIA {
      @Override
      public Color getColor() {
        return new Color(255, 0, 255);
      }
    },
    // Netscape alias for cyan
    AQUA {
      @Override
      public Color getColor() {
        return Color.CYAN;
      }
    },
    LIME {
      @Override
      public Color getColor() {
        return new Color(204, 255, 0);
      }
    },
    MAROON {
      @Override
      public Color getColor() {
        return new Color(128, 0, 0);
      }
    },
    OLIVE {
      @Override
      public Color getColor() {
        return new Color(128, 128, 0);
      }
    },
    PURPLE {
      @Override
      public Color getColor() {
        return new Color(128, 0, 128);
      }
    },
    SILVER {
      @Override
      public Color getColor() {
        return new Color(192, 192, 192);
      }
    },
    WHITE {
      @Override
      public Color getColor() {
        return Color.WHITE;
      }
    };

    public abstract Color getColor();

    public static final int length = Colors.values().length;

    public static final Color resolveIndex(int i) {
      return Colors.values()[i % Colors.length].getColor();
    }
  };
Example #21
0
 public static final Color resolveIndex(int i) {
   return Colors.values()[i % Colors.length].getColor();
 }
Example #22
0
 public void prep(Buffer buf) {
   Colors p = buf.get(colors);
   if (p != null) buf.put(colors, p.combine(this));
   else buf.put(colors, this);
 }
Example #23
0
 @Koan
 public void basicEnumsAccess() {
   Colors[] colorArray = Colors.values();
   assertEquals(colorArray[2], Colors.Green);
 }
Example #24
0
  public static void main(String[] args) {
    Mix proxyMe = new Mix();
    Object proxy = createProxy(proxyMe);

    if (!Proxy.isProxyClass(proxy.getClass())) System.err.println("not a proxy class?");
    if (Proxy.getInvocationHandler(proxy) == null)
      System.err.println("ERROR: Proxy.getInvocationHandler is null");

    /* take it for a spin; verifies instanceof constraint */
    Shapes shapes = (Shapes) proxy;
    shapes.circle(3);
    shapes.rectangle(10, 20);
    shapes.blob();
    Quads quads = (Quads) proxy;
    quads.rectangle(15, 25);
    quads.trapezoid(6, 81.18, 4);
    Colors colors = (Colors) proxy;
    colors.red(1.0f);
    colors.blue(777);
    colors.mauve("sorry");
    colors.blob();

    try {
      shapes.upChuck();
      System.out.println("Didn't get expected exception");
    } catch (IndexOutOfBoundsException ioobe) {
      System.out.println("Got expected ioobe");
    }
    try {
      shapes.upCheck();
      System.out.println("Didn't get expected exception");
    } catch (InterruptedException ie) {
      System.out.println("Got expected ie");
    }

    /*
     * Exercise annotations on Proxy classes.  This is mostly to ensure
     * that annotation calls work correctly on generated classes.
     */
    System.out.println("");
    Method[] methods = proxy.getClass().getDeclaredMethods();
    Arrays.sort(
        methods,
        new Comparator<Method>() {
          public int compare(Method o1, Method o2) {
            int result = o1.getName().compareTo(o2.getName());
            if (result != 0) {
              return result;
            }
            return o1.getReturnType().getName().compareTo(o2.getReturnType().getName());
          }
        });
    System.out.println(
        "Proxy interfaces: " + Arrays.deepToString(proxy.getClass().getInterfaces()));
    System.out.println("Proxy methods: " + Arrays.deepToString(methods));
    Method meth = methods[methods.length - 1];
    System.out.println("Decl annos: " + Arrays.deepToString(meth.getDeclaredAnnotations()));
    Annotation[][] paramAnnos = meth.getParameterAnnotations();
    System.out.println(
        "Param annos (" + paramAnnos.length + ") : " + Arrays.deepToString(paramAnnos));
  }
Example #25
0
  /*package*/ PointsStyleFrame(PointsView[] ptv, boolean isLine) {
    _ptv = ptv;
    _panel = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    JRadioButton line = new JRadioButton("Line");
    line.setSelected(isLine);
    line.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {}
        });
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    _panel.add(line, c);

    JRadioButton marks = new JRadioButton("Marks");
    marks.setSelected(!isLine);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 1;
    c.gridy = 0;
    _panel.add(marks, c);

    JComboBox lineStyles = new JComboBox(PointsView.Line.values());
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 1;
    _panel.add(lineStyles, c);

    JComboBox markStyles = new JComboBox(PointsView.Mark.values());
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 1;
    c.gridy = 1;
    _panel.add(markStyles, c);

    //    JLabel sizeLabel = new JLabel("Size:");
    //    c.fill = GridBagConstraints.HORIZONTAL;
    //    c.anchor = GridBagConstraints.CENTER;
    //    c.weightx = 10;
    //    c.gridx = 0;
    //    c.gridy = 2;
    //    _panel.add(sizeLabel,c);

    JComboBox size = new JComboBox(_sizes);
    size.setEditable(true);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 1;
    c.gridy = 2;
    _panel.add(size, c);

    JComboBox colors = new JComboBox(Colors.values());
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 1;
    c.gridy = 3;
    _panel.add(colors, c);

    add(_panel);
    pack();
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
  }
Example #26
0
 @Override
 public byte[] convertObjTypeToCassType(Colors value) {
   return value.getName().getBytes();
 }