@Override
  public void paintComponent(Graphics graphics) {
    super.paintComponent(graphics);
    //		 painting only if approved
    if (show) {
      // init graphics
      Graphics2D g = (Graphics2D) graphics;

      int pixWidth = getWidth() - 2 * MARGIN;
      int pixHeight = getHeight() - 2 * MARGIN;

      // painting background
      g.drawImage(this.image, MARGIN, MARGIN, pixWidth, pixHeight, Color.WHITE, null);

      // painting transparent class overlay
      g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alphaLevel));
      g.drawImage(this.classImage, MARGIN, MARGIN, pixWidth, pixHeight, Color.WHITE, null);
      g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
      // painting points
      drawPoints(g);

      // painting Legend
      drawLegend(graphics, this.dataTable, colorColumn);

      // paint Tooltip
      drawToolTip((Graphics2D) graphics);
    }
  }
 @Override
 protected void recalculateBackgroundImage() {
   super.recalculateBackgroundImage();
   this.classImage = new BufferedImage(IMAGE_WIDTH, IMAGE_HEIGHT, BufferedImage.TYPE_INT_ARGB);
   int width = IMAGE_WIDTH / dimensions[0];
   int height = IMAGE_HEIGHT / dimensions[1];
   for (int i = 0; i < dimensions[0]; i++) {
     for (int j = 0; j < dimensions[1]; j++) {
       // using 1 as scale factor, because SOMClasscolorzier needs original classvalues!
       interpolateRect(
           classImage,
           width * i,
           height * j,
           width,
           height,
           classificationMatrix,
           i,
           j,
           1,
           colorizer);
     }
   }
 }
 @Override
 protected void createMatrices() {
   List<Attribute> attributes = new ArrayList<Attribute>(exampleSet.getAttributes().size());
   for (Attribute attribute : exampleSet.getAttributes()) {
     attributes.add((Attribute) attribute.clone());
   }
   MemoryExampleTable table = new MemoryExampleTable(attributes);
   for (int x = 0; x < dimensions[0]; x++) {
     for (int y = 0; y < dimensions[1]; y++) {
       DataRow row = new DoubleArrayDataRow(net.getNodeWeights(new int[] {x, y}));
       table.addDataRow(row);
     }
   }
   ExampleSet set = table.createExampleSet();
   this.classificationMatrix = new double[dimensions[0]][dimensions[1]];
   try {
     set = model.apply(set);
     Iterator<Example> exampleIterator = set.iterator();
     for (int x = 0; x < dimensions[0]; x++) {
       for (int y = 0; y < dimensions[1]; y++) {
         Example example = exampleIterator.next();
         classificationMatrix[x][y] =
             example.getValue(example.getAttributes().getPredictedLabel());
       }
     }
   } catch (OperatorException e) {
     // LogService.getGlobal().log("Cannot use Model for prediction of node label: " +
     // e.getMessage(), LogService.WARNING);
     LogService.getRoot()
         .log(
             Level.WARNING,
             "com.rapidminer.operator.visualization.SOMModelPlotter.using_model_for_prediction_error"
                 + e.getMessage());
   }
   super.createMatrices();
 }