Package jmt.engine.jwat

Examples of jmt.engine.jwat.TimeConsumingWorker


        Redraw = false;
        Graphics grap = chart.getGraphics();
        grap.setColor(Color.GRAY);
        grap.fillRect(0, 0, WIDTH_TOT * model.getMatrix().getNumVariables() + 1, HEIGHT_TOT * model.getMatrix().getNumVariables() + 1);
        grap.drawImage(chart, 0, 0, null);
        TimeConsumingWorker worker = new TimeConsumingWorker(new ProgressMonitorShow(this, "Constructin Dispersion Matrix...", 1)) {
          @Override
          public Object construct() {
            if (model.getMatrix() != null) {
              Graphics g = chart.getGraphics();
              VariableNumber Elenco[] = model.getMatrix().getVariables();
              try {
                // Pulizia dell'immagine
                g.setColor(Color.WHITE);
                g.fillRect(0, 0, WIDTH_TOT * Elenco.length + 1, HEIGHT_TOT * Elenco.length + 1);

                initShow((Elenco.length * Elenco.length));

                int l = 0;
                // Disegno dei grafici
                for (int row = 0; row < Elenco.length; row++) {
                  for (int col = 0; col < Elenco.length; col++) {
                    g.setColor(Color.BLACK);
                    g.drawRect(col * WIDTH_TOT, row * HEIGHT_TOT, WIDTH_TOT, HEIGHT_TOT);
                    if (col == row) {
                      // Scrittura della variabile
                      Graphics2D gr = (Graphics2D) g;
                      gr.setFont(new Font("Arial", Font.BOLD, 13));
                      FontRenderContext context = gr.getFontRenderContext();
                      Font f = new Font("Arial", Font.BOLD, 12);
                      Rectangle2D bounds = f.getStringBounds(Elenco[row].getName(), context);

                      g.setFont(new Font("Arial", Font.BOLD, 12));
                      g.drawString(Elenco[row].getName(), col * WIDTH_TOT + (WIDTH_TOT - (int) bounds.getWidth()) / 2, row
                          * HEIGHT_TOT - (int) bounds.getY() + (HEIGHT_TOT - (int) bounds.getHeight()) / 2);
                      g.setFont(new Font("Arial", Font.PLAIN, 12));
                    } else {
                      int[] quantiliX = Elenco[col].getUniStats().getQuantili();
                      int[] quantiliY = Elenco[row].getUniStats().getQuantili();

                      int startx = col * WIDTH_TOT + 5;
                      int starty = row * HEIGHT_TOT + 5;

                      double xRange = Elenco[col].getUniStats().getRangeValue();
                      double yRange = Elenco[row].getUniStats().getRangeValue();
                      double xmin = Elenco[col].getUniStats().getMinValue();
                      double ymax = Elenco[row].getUniStats().getMaxValue();
                      //Draw Border line
                      g.setColor(Color.BLACK);
                      g.drawRect(startx, starty, WIDTH_GRAPH, HEIGHT_GRAPH);
                      //Draw gray line
                      g.setColor(Color.LIGHT_GRAY);
                      for (int i = 1; i < 9; i++) {
                        g.drawLine(startx, starty + (i * (HEIGHT_GRAPH / 9)), startx + WIDTH_GRAPH, starty
                            + (i * (HEIGHT_GRAPH / 9)));
                        g.drawLine(startx + (i * (WIDTH_GRAPH / 9)), starty, startx + (i * (WIDTH_GRAPH / 9)), starty
                            + HEIGHT_GRAPH);
                      }
                      //Draw reference line red 
                      g.setColor(Color.RED);
                      g.drawLine(startx, starty + HEIGHT_GRAPH, startx + WIDTH_GRAPH, starty);
                      //Draw QQ-plot
                      g.setColor(Color.BLUE);
                      for (int i = 1; i < quantiliX.length; i++) {
                        g.fillOval(startx + (int) (((Elenco[col].getValue(quantiliX[i]) - xmin) / xRange) * WIDTH_GRAPH),
                            (starty + (int) (((ymax - (Elenco[row].getValue(quantiliY[i]))) / yRange) * HEIGHT_GRAPH)),
                            1, 1);
                      }
                    }
                  }
                }
              } catch (Exception e) {
                g.setColor(Color.WHITE);
                g.fillRect(0, 0, 300, 100);
                g.setColor(Color.BLACK);
                g.drawString("With this data the graphic cannot be create", 50, 50);
              }
              updateInfos((Elenco.length * Elenco.length) + 1, "End", false);
            }
            return null;
          }

          @Override
          public void finished() {
            DispersionPanel.this.repaint();
          }
        };
        worker.start();
      } else {
        g.drawImage(chart, 0, 0, null);
      }
    }
View Full Code Here


      }
    }
    // Disegno punti
    if (first) {
      first = false;
      new TimeConsumingWorker(new ProgressMonitorShow(this, "Plotting observations ...", 100)) {
        @Override
        public Object construct() {
          Graphics2D g1 = (Graphics2D) graph.getGraphics();

          g1.setColor(Color.BLACK);
View Full Code Here

      }
    }
    // Disegno punti
    if (first) {
      first = false;
      new TimeConsumingWorker(new ProgressMonitorShow(this, "Plotting observations ...", 100)) {
        @Override
        public Object construct() {
          Graphics2D g1 = (Graphics2D) graph.getGraphics();

          g1.setColor(Color.BLACK);
View Full Code Here

        Redraw = false;
        Graphics grap = chart.getGraphics();
        grap.setColor(Color.GRAY);
        grap.fillRect(0, 0, WIDTH_TOT * model.getMatrix().getNumVariables() + 1, HEIGHT_TOT * model.getMatrix().getNumVariables() + 1);
        grap.drawImage(chart, 0, 0, null);
        TimeConsumingWorker worker = new TimeConsumingWorker(new ProgressMonitorShow(this, "Constructin Dispersion Matrix...", 1)) {
          @Override
          public Object construct() {
            Graphics g = chart.getGraphics();
            VariableNumber Elenco[] = model.getMatrix().getVariables();
            try {
              if (fuzzyN != -1) {
                // Pulizia dell'immagine
                g.setColor(Color.WHITE);
                g.fillRect(0, 0, WIDTH_TOT * Elenco.length + 1, HEIGHT_TOT * Elenco.length + 1);

                initShow(10000 * (Elenco.length * Elenco.length));

                short[] c1 = ((ClusteringInfosFuzzy) ((FuzzyKMean) (session.getListOfClustering().get(clustering)))
                    .getClusteringInfos(curClust)).getAssignment();
                int[] v = ((FuzzyKMean) (session.getListOfClustering().get(clustering))).getVarClust();
                int l = 0;
                // Disegno dei grafici
                for (int row = 0; row < Elenco.length; row++) {
                  for (int col = 0; col < Elenco.length; col++) {
                    g.setColor(Color.BLACK);
                    g.drawRect(col * WIDTH_TOT, row * HEIGHT_TOT, WIDTH_TOT, HEIGHT_TOT);
                    if (col == row) {
                      // Scrittura della variabile
                      Graphics2D gr = (Graphics2D) g;
                      gr.setFont(new Font("Arial", Font.BOLD, 13));
                      FontRenderContext context = gr.getFontRenderContext();
                      Font f = new Font("Arial", Font.BOLD, 12);
                      Rectangle2D bounds = f.getStringBounds(Elenco[row].getName(), context);

                      g.setFont(new Font("Arial", Font.BOLD, 12));
                      g.drawString(Elenco[row].getName(), col * WIDTH_TOT + (WIDTH_TOT - (int) bounds.getWidth()) / 2, row
                          * HEIGHT_TOT - (int) bounds.getY() + (HEIGHT_TOT - (int) bounds.getHeight()) / 2);
                      //UPDATE 02/11/2006:  +visualizzazione variabile clusterizzata
                      if (l < v.length && v[l] == col) {
                        g.drawString("(Clusterized)", col * WIDTH_TOT + 10, row * HEIGHT_TOT - (int) bounds.getY()
                            + (HEIGHT_TOT - (int) bounds.getHeight()) / 2 + 15);
                        l++;
                      }
                      g.setFont(new Font("Arial", Font.PLAIN, 12));
                    } else {
                      // Calcolo del passo del grafico
                      double yFoot = HEIGHT_GRAPH / Elenco[row].getUniStats().getRangeValue();
                      double xFoot = WIDTH_GRAPH / Elenco[col].getUniStats().getRangeValue();
                      // Plottaggio del grafico
                      for (int i = 1; i <= WIDTH_GRAPH; i++) {
                        boolean[] done = new boolean[101];
                        int k = 1;
                        for (int j = Elenco[col].getStartInt(i); j < Elenco[col].getEndInt(i); j++) {
                          if ((int) ((Elenco[col].getValue(j, row) - Elenco[row].getUniStats().getMinValue()) * yFoot) >= 0) {
                            if (!done[(int) ((Elenco[col].getValue(j, row) - Elenco[row].getUniStats().getMinValue()) * yFoot)]) {
                              updateInfos(((row * Elenco.length) + (col)) * 10000 + i + (k++), "Plotting scatter "
                                  + ((row * Elenco.length) + (col + 1)), false);
                              //g.setColor(JavaWatColor.getColor(((Integer)(c.get(Elenco[col].getObsID(j)-1))).intValue()));

                              g.setColor(JavaWatColor.getColor(c1[Elenco[col].getObsID(j) - 1]));
                              g
                                  .fillOval(
                                      col
                                          * WIDTH_TOT
                                          + 5
                                          + /* i - 1,*/
                                          (int) (((Elenco[col].getValue(j) - Elenco[col].getUniStats()
                                              .getMinValue())) * xFoot) - 1,
                                      (((row + 1) * HEIGHT_TOT) - 5 - (int) (((Elenco[col].getValue(j, row) - Elenco[row]
                                          .getUniStats().getMinValue())) * yFoot)), 1, 1);
                              done[(int) ((Elenco[col].getValue(j, row) - Elenco[row].getUniStats().getMinValue()) * yFoot)] = true;
                            }
                          }
                        }

                      }
                    }
                  }
                }
              } else {
                g.setColor(Color.WHITE);
                g.fillRect(0, 0, 300, 100);
                g.setColor(Color.BLACK);
                g.drawString("With this data the graphic cannot be create", 50, 50);
              }
            } catch (Exception e) {
              g.setColor(Color.WHITE);
              g.fillRect(0, 0, 300, 100);
              g.setColor(Color.BLACK);
              g.drawString("With this data the graphic cannot be create", 50, 50);
            }
            updateInfos(10000 * (Elenco.length * Elenco.length) + 1, "End", false);
            return null;
          }

          @Override
          public void finished() {
            DispersionPanel.this.repaint();
          }
        };
        worker.start();
      } else {
        g.drawImage(chart, 0, 0, null);
      }
    }
View Full Code Here

        Graphics grap = chart.getGraphics();
        grap.setColor(Color.GRAY);
        grap.fillRect(0, 0, WIDTH_TOT * model.getMatrix().getNumVariables() + 1, HEIGHT_TOT * model.getMatrix().getNumVariables() + 1);
        grap.drawImage(chart, 0, 0, null);
        //SwingWorker worker = new SwingWorker()
        TimeConsumingWorker worker = new TimeConsumingWorker(new ProgressMonitorShow(DispMatrix.this, "Plotting scatters...", 1)) {
          @Override
          public Object construct() {
            //doWork();
            Graphics g = chart.getGraphics();
            VariableNumber Elenco[] = model.getMatrix().getVariables();
            try {
              // Pulizia dell'immagine
              g.setColor(Color.WHITE);
              g.fillRect(0, 0, WIDTH_TOT * Elenco.length + 1, HEIGHT_TOT * Elenco.length + 1);

              initShow(10000 * (Elenco.length * Elenco.length));

              int Prog = 0;

              // Disegno dei grafici
              for (int row = 0; row < Elenco.length; row++) {
                for (int col = 0; col < Elenco.length; col++) {
                  g.setColor(Color.BLACK);
                  g.drawRect(col * WIDTH_TOT, row * HEIGHT_TOT, WIDTH_TOT, HEIGHT_TOT);
                  if (col == row) {
                    // Scrittura della variabile
                    Graphics2D gr = (Graphics2D) g;
                    gr.setFont(new Font("Arial", Font.BOLD, 13));
                    FontRenderContext context = gr.getFontRenderContext();
                    Font f = new Font("Arial", Font.BOLD, 12);
                    Rectangle2D bounds = f.getStringBounds(Elenco[row].getName(), context);

                    g.setFont(new Font("Arial", Font.BOLD, 12));
                    g.drawString(Elenco[row].getName(), col * WIDTH_TOT + (WIDTH_TOT - (int) bounds.getWidth()) / 2, row
                        * HEIGHT_TOT - (int) bounds.getY() + (HEIGHT_TOT - (int) bounds.getHeight()) / 2);
                    g.setFont(new Font("Arial", Font.PLAIN, 12));
                  } else {
                    // Calcolo del passo del grafico
                    double yFoot = HEIGHT_GRAPH / Elenco[row].getUniStats().getRangeValue();
                    double xFoot = WIDTH_GRAPH / Elenco[col].getUniStats().getRangeValue();
                    // Plottaggio del grafico
                    g.setColor(Color.RED);
                    for (int i = 1; i <= WIDTH_GRAPH; i++) {
                      boolean[] done = new boolean[101];
                      for (int j = Elenco[col].getStartInt(i); j < Elenco[col].getEndInt(i); j++) {
                        int k = 1;
                        if ((int) ((Elenco[col].getValue(j, row) - Elenco[row].getUniStats().getMinValue()) * yFoot) > 0) {
                          if (!done[(int) ((Elenco[col].getValue(j, row) - Elenco[row].getUniStats().getMinValue()) * yFoot)]) {
                            updateInfos(((row * Elenco.length) + (col)) * 10000 + i + (k++), "Plotting scatter "
                                + ((row * Elenco.length) + (col + 1)), false);
                            g.fillOval(col * WIDTH_TOT + 5 + /* i - 1,*/
                            (int) (((Elenco[col].getValue(j) - Elenco[col].getUniStats().getMinValue())) * xFoot) - 1,
                                (((row + 1) * HEIGHT_TOT) - 5 - (int) (((Elenco[col].getValue(j, row) - Elenco[row]
                                    .getUniStats().getMinValue())) * yFoot)), 1, 1);
                            done[(int) ((Elenco[col].getValue(j, row) - Elenco[row].getUniStats().getMinValue()) * yFoot)] = true;
                          }
                        }
                      }

                    }
                  }
                }
              }
            } catch (Exception e) {
              g.setColor(Color.WHITE);
              g.fillRect(0, 0, 300, 100);
              g.setColor(Color.BLACK);
              g.drawString("With this data the graphic cannot be create", 50, 50);
              DispersionPanel.this.repaint();
              e.printStackTrace();

            }
            updateInfos(10000 * (Elenco.length * Elenco.length) + 1, "End", false);
            return null;
          }

          @Override
          public void finished() {
            DispersionPanel.this.repaint();
          }
        };
        worker.start();
      } else {
        g.drawImage(chart, 0, 0, null);
      }
    }
View Full Code Here

      }
    }
    // Disegno punti
    if (first) {
      first = false;
      new TimeConsumingWorker(new ProgressMonitorShow(this, "Plotting observations ...", 100)) {
        @Override
        public Object construct() {
          Graphics2D g1 = (Graphics2D) graph.getGraphics();

          g1.setColor(Color.BLACK);
View Full Code Here

      }
    }
    // Disegno punti
    if (first) {
      first = false;
      new TimeConsumingWorker(new ProgressMonitorShow(this, "Plotting observations ...", 100)) {
        @Override
        public Object construct() {
          Graphics2D g1 = (Graphics2D) graph.getGraphics();

          g1.setColor(Color.BLACK);
View Full Code Here

      }
    }
    // Disegno punti
    if (first) {
      first = false;
      new TimeConsumingWorker(new ProgressMonitorShow(this, "Plotting observations ...", 100)) {
        @Override
        public Object construct() {
          VectorGraphics g1 = VectorGraphics.create(graph.getGraphics());

          g1.setColor(Color.BLACK);
View Full Code Here

        Redraw = false;
        Graphics grap = chart.getGraphics();
        grap.setColor(Color.GRAY);
        grap.fillRect(0, 0, WIDTH_TOT * model.getMatrix().getNumVariables() + 1, HEIGHT_TOT * model.getMatrix().getNumVariables() + 1);
        grap.drawImage(chart, 0, 0, null);
        TimeConsumingWorker worker = new TimeConsumingWorker(new ProgressMonitorShow(this, "Constructin Dispersion Matrix...", 1)) {
          @Override
          public Object construct() {
            Graphics g = chart.getGraphics();
            VariableNumber Elenco[] = model.getMatrix().getVariables();
            try {
              // Pulizia dell'immagine
              g.setColor(Color.WHITE);
              g.fillRect(0, 0, WIDTH_TOT * Elenco.length + 1, HEIGHT_TOT * Elenco.length + 1);

              initShow(10000 * (Elenco.length * Elenco.length));

              short[][] c1 = ((KMean) (session.getListOfClustering().get(clustering))).getAsseg();
              int[] v = ((KMean) (session.getListOfClustering().get(clustering))).getVarClust();
              int l = 0;
              // Disegno dei grafici
              for (int row = 0; row < Elenco.length; row++) {
                for (int col = 0; col < Elenco.length; col++) {
                  g.setColor(Color.BLACK);
                  g.drawRect(col * WIDTH_TOT, row * HEIGHT_TOT, WIDTH_TOT, HEIGHT_TOT);
                  if (col == row) {
                    // Scrittura della variabile
                    Graphics2D gr = (Graphics2D) g;
                    gr.setFont(new Font("Arial", Font.BOLD, 13));
                    FontRenderContext context = gr.getFontRenderContext();
                    Font f = new Font("Arial", Font.BOLD, 12);
                    Rectangle2D bounds = f.getStringBounds(Elenco[row].getName(), context);

                    g.setFont(new Font("Arial", Font.BOLD, 12));
                    g.drawString(Elenco[row].getName(), col * WIDTH_TOT + (WIDTH_TOT - (int) bounds.getWidth()) / 2, row
                        * HEIGHT_TOT - (int) bounds.getY() + (HEIGHT_TOT - (int) bounds.getHeight()) / 2);
                    //UPDATE 02/11/2006:  +visualizzazione variabile clusterizzata
                    if (l < v.length && v[l] == col) {
                      g.drawString("(Clusterized)", col * WIDTH_TOT + 10, row * HEIGHT_TOT - (int) bounds.getY()
                          + (HEIGHT_TOT - (int) bounds.getHeight()) / 2 + 15);
                      l++;
                    }
                    g.setFont(new Font("Arial", Font.PLAIN, 12));
                  } else {
                    // Calcolo del passo del grafico
                    double yFoot = HEIGHT_GRAPH / Elenco[row].getUniStats().getRangeValue();
                    double xFoot = WIDTH_GRAPH / Elenco[col].getUniStats().getRangeValue();
                    // Plottaggio del grafico
                    for (int i = 1; i <= WIDTH_GRAPH; i++) {
                      boolean[] done = new boolean[101];
                      int k = 1;
                      for (int j = Elenco[col].getStartInt(i); j < Elenco[col].getEndInt(i); j++) {
                        if ((int) ((Elenco[col].getValue(j, row) - Elenco[row].getUniStats().getMinValue()) * yFoot) >= 0) {
                          if (!done[(int) ((Elenco[col].getValue(j, row) - Elenco[row].getUniStats().getMinValue()) * yFoot)]) {
                            updateInfos(((row * Elenco.length) + (col)) * 10000 + i + (k++), "Plotting scatter "
                                + ((row * Elenco.length) + (col + 1)), false);
                            g.setColor(JavaWatColor.getColor(c1[curClust][Elenco[col].getObsID(j) - 1]));
                            g.fillOval(col * WIDTH_TOT + 5 + /*i - 1,*/
                            (int) (((Elenco[col].getValue(j) - Elenco[col].getUniStats().getMinValue())) * xFoot) - 1,
                                (((row + 1) * HEIGHT_TOT) - 5 - (int) (((Elenco[col].getValue(j, row) - Elenco[row]
                                    .getUniStats().getMinValue())) * yFoot)), 1, 1);
                            done[(int) ((Elenco[col].getValue(j, row) - Elenco[row].getUniStats().getMinValue()) * yFoot)] = true;
                          }
                        }
                      }

                    }
                  }
                }
              }
            } catch (Exception e) {
              g.setColor(Color.WHITE);
              g.fillRect(0, 0, 300, 100);
              g.setColor(Color.BLACK);
              g.drawString("With this data the graphic cannot be create", 50, 50);
              e.printStackTrace();
            }
            updateInfos(10000 * (Elenco.length * Elenco.length) + 1, "End", false);
            return null;
          }

          @Override
          public void finished() {
            DispersionPanel.this.repaint();
          }
        };
        worker.start();
      } else {
        g.drawImage(chart, 0, 0, null);
      }
    }
View Full Code Here

TOP

Related Classes of jmt.engine.jwat.TimeConsumingWorker

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.