congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Graphics
Code IndexAdd Tabnine to your IDE (free)

How to use
Graphics
in
smile.plot

Best Java code snippets using smile.plot.Graphics (Showing top 20 results out of 315)

origin: com.github.haifengl/smile-plot

@Override
public void paint(Graphics g) {
  Font f = g.getFont();
  if (font != null) {
    g.setFont(font);
  }
  Color c = g.getColor();
  g.setColor(getColor());
  g.drawText(text, horizontalReference, verticalReference, rotation, coord);
  g.setColor(c);
  if (font != null) {
    g.setFont(f);
  }
}
origin: stackoverflow.com

 ObjectChoiceField choice = new ObjectChoiceField()
{      
 protected void paint(Graphics graphics)
 {
  // Get the current selected Choice
  Choice item = (Choice) this.getChoice(getSelectedIndex());

  int xOffset = 5; // 5 px padding on the left
  graphics.drawBitmap(xOffset, 0, 
            item.image.getWidth(), 
            item.image.getHeight(), 
            item.image, 
            0, 0);
  // Add text after the image and 10px padding.
  xOffset += item.image.getWidth() + 10; 
  graphics.drawText(item.label, xOfffset, 0);
 }            
};
origin: com.github.haifengl/smile-plot

@Override
public void paint(Graphics g) {
  Color c = g.getColor();
  g.setColor(getColor());
  double[] lowerEnd = g.getLowerBound();
  lowerEnd[0] = Math.min(lowerEnd[0], lowerEnd[1]);
  lowerEnd[1] = lowerEnd[0];
  double[] upperEnd = g.getUpperBound();
  upperEnd[0] = Math.max(upperEnd[0], upperEnd[1]);
  upperEnd[1] = upperEnd[0];
  g.drawLine(lowerEnd, upperEnd);
  for (int i = 0; i < data.length; i++) {
    g.drawPoint('o', data[i]);
  }
  g.setColor(c);
}

origin: com.github.haifengl/smile-plot

@Override
public void paint(Graphics g) {
  Color c = g.getColor();
  g.setColor(getColor());
  for (int i = 0; i < p1.length; i++) {
    g.drawLine(p1[i], p2[i]);
  }
  g.setColor(c);
}
origin: com.github.haifengl/smile-plot

  @Override
  public void paint(Graphics g) {
    Color c = g.getColor();
    g.setColor(getColor());
    g.drawLineBaseRatio(points);
    g.setColor(c);
  }
}
origin: com.github.haifengl/smile-plot

  @Override
  public void paint(Graphics g) {
    Color c = g.getColor();
    g.setColor(getColor());

    g.drawPoint(legend, point);
    g.setColor(c);
  }
}
origin: com.github.haifengl/smile-plot

@Override
public void paint(Graphics g) {
  Color c = g.getColor();
        g.setColor(Color.WHITE);
      } else {
        int k = (int) ((z[i][j] - min) / width);
        g.setColor(palette[k]);
      g.fillPolygon(hexagon[i][j]);
  g.clearClip();
    g.setColor(palette[i]);
    g.fillRectBaseRatio(start, end);
    start[1] += height;
    end[1] += height;
  g.setColor(Color.BLACK);
  start[1] -= height;
  end[1] = 0.15 - height;
  g.drawRectBaseRatio(start, end);
  start[0] = 1.14;
  double log = Math.log10(Math.abs(max));
  int decimal = 1;
  if (log < 0) decimal = (int) -log + 1;
  g.drawTextBaseRatio(String.valueOf(Math.round(max, decimal)), 0.0, 1.0, start);
  decimal = 1;
origin: com.github.haifengl/smile-plot

@Override
public void paint(Graphics g) {
  Color c = g.getColor();
  g.setColor(getColor());
  for (int i = 0; i < data.length; i++) {
    for (int j = 0; j < data[i].length - 1; j++) {
      if (drawNodes) g.drawPoint('o', data[i][j]);
      g.drawLine(data[i][j], data[i][j+1]);
    }
    if (drawNodes) g.drawPoint('o', data[i][data[i].length - 1]);
  }
  for (int i = 0; i < data.length - 1; i++) {
    for (int j = 0; j < data[i].length; j++) {
      g.drawLine(data[i][j], data[i+1][j]);
    }
  }
  
  g.setColor(c);
}

origin: com.github.haifengl/smile-plot

@Override
public void paint(Graphics g) {
  Color c = g.getColor();
  g.setColor(Color.BLACK);
  for (int i = 0; i < data.length; i++) {
    g.drawLine(leftBottom[i], leftTop[i]);
    g.drawLine(leftTop[i], rightTop[i]);
    g.drawLine(rightTop[i], rightBottom[i]);
    g.drawLine(rightBottom[i], leftBottom[i]);
  }
  g.setColor(getColor());
  for (int i = 0; i < data.length; i++) {
    g.fillPolygon(0.2f, leftBottom[i], leftTop[i], rightTop[i], rightBottom[i]);
  }
  g.setColor(c);
}
origin: com.github.haifengl/smile-plot

  @Override
  public void paint(Graphics g) {
    Color c = g.getColor();
    g.setColor(getColor());

    Stroke s = g.getStroke();
    if (stroke != null) {
      g.setStroke(stroke);
    }

    g.drawLine(points);

    if (stroke != null) {
      g.setStroke(s);
    }
    g.setColor(c);
  }
}
origin: com.github.haifengl/smile-plot

/**
 * Draw a string. Reference point is the center of string. The coordinates
 * are logical coordinates.
 */
public void drawText(String label, double[] coord) {
  drawText(label, 0.5, 0.5, 0.0, coord);
}
origin: com.github.haifengl/smile-plot

@Override
public void paint(Graphics g) {
  Color c = g.getColor();
  g.setColor(getColor());
  if (labels != null) {
    for (int i = 0; i < data.length; i++) {
      g.drawText(labels[i], data[i]);
    }
  } else {
    if (y == null) {
      for (int i = 0; i < data.length; i++) {
        g.drawPoint(legend, data[i]);
      }
    } else {
      for (int i = 0; i < data.length; i++) {
        if (palette != null) {
          g.setColor(palette[classLookupTable.get(y[i])]);
        }
        
        if (legends != null) {
          g.drawPoint(legends[classLookupTable.get(y[i])], data[i]);
        } else {
          g.drawPoint(legend, data[i]);
        }
      }
    }
  }
  g.setColor(c);
}
origin: com.github.haifengl/smile-plot

@Override
public void paintComponent(java.awt.Graphics g) {
  Graphics2D g2d = (Graphics2D) g;
  graphics.setGraphics(g2d);
  graphics.clip();
  int k = 0;
  graphics.clearClip();
origin: com.github.haifengl/smile-plot

/**
 * Draw poly line. The coordinates are in logical coordinates.
 */
public void drawLine(double[]... coord) {
  int[][] sc = new int[coord.length][];
  for (int i = 0; i < sc.length; i++) {
    sc[i] = projection.screenProjection(coord[i]);
  }
  drawLine(sc);
}
origin: com.github.haifengl/smile-plot

/**
 * Draw a dot. The coordinates are in logical coordinates.
 */
public void drawPoint(double... coord) {
  drawPoint('.', coord);
}
origin: com.github.haifengl/smile-plot

/**
 * Initialize the Graphics object.
 */
private void initGraphics() {
  if (base.dimension == 2) {
    graphics = new Graphics(new Projection2D(this));
  } else {
    graphics = new Graphics(new Projection3D(this));
  }
}
origin: com.github.haifengl/smile-plot

g.clearClip();
Color c = g.getColor();
  g.setColor(colors[i]);
  g.fillRectBaseRatio(start, end);
  start[1] += height;
  end[1] += height;
g.setColor(Color.BLACK);
start[1] -= height;
end[1] = 0.15 - height;
g.drawRectBaseRatio(start, end);
start[0] = 1.14;
double log = Math.log10(Math.abs(levels[levels.length-1]));
  decimal = (int) -log + 1;
g.drawTextBaseRatio(String.valueOf(Math.round(levels[levels.length-1], decimal)), 0.0, 1.0, start);
  decimal = (int) -log + 1;
g.drawTextBaseRatio(String.valueOf(Math.round(levels[0], decimal)), 0.0, 0.0, start);
g.setColor(c);
origin: com.github.haifengl/smile-plot

@Override
public void paint(Graphics g) {
  Color c = g.getColor();
  g.setColor(getColor());
    end[0] = i + 0.6;
    end[1] = quantiles[i][0];
    g.drawLine(start, end);
    end[0] = i + 0.6;
    end[1] = quantiles[i][4];
    g.drawLine(start, end);
    end[0] = i + 0.8;
    end[1] = quantiles[i][2];
    g.drawLine(start, end);
    end[0] = i + 0.5;
    end[1] = quantiles[i][1];
    g.drawLine(start, end);
    end[0] = i + 0.5;
    end[1] = quantiles[i][3];
    g.drawLine(start, end);
    end[0] = i + 0.8;
    end[1] = quantiles[i][1];
    g.drawRect(start, end);
      if (data[i][j] < quantiles[i][6] || data[i][j] > quantiles[i][7]) {
origin: com.github.haifengl/smile-plot

@Override
public void paint(Graphics g) {
  Color c = g.getColor();
  g.setColor(getColor());
      g.drawLine(data[i][j], data[i][j + 1]);
      g.drawLine(data[i][j], data[i + 1][j]);
      g.setColor(palette[k]);
      g.fillPolygon(data[triangles[i][0]][triangles[i][1]], data[triangles[i][2]][triangles[i][3]], data[triangles[i][4]][triangles[i][5]]);
  g.setColor(c);
origin: com.github.haifengl/smile-plot

/**
 * Draw a string with given rotation angle. Reference point is the center
 * of string. The coordinates are logical coordinates. The angle of rotation
 * is in radians.
 */
public void drawText(String label, double rotation, double[] coord) {
  drawText(label, 0.5, 0.5, rotation, coord);
}
smile.plotGraphics

Javadoc

Graphics provides methods to draw graphical primitives in logical/mathematical coordinates. The mathematical coordinates are translated into Java2D coordinates based on suitiabel projection method. Both 2D and 3D shapes are supported.

Most used methods

  • drawText
    Draw a string. Reference point is the center of string. The coordinates are logical coordinates.
  • <init>
    Constructor.
  • clearClip
    Clear the restriction of the draw area.
  • clip
    Restrict the draw area to the valid base coordinate space.
  • drawBitmap
  • drawLine
    Draw poly line.
  • drawLineBaseRatio
    Draw poly line. The logical coordinates are proportional to the base coordinates.
  • drawPoint
    Draw a dot. The coordinates are in logical coordinates.
  • drawRect
    Draw the outline of the specified rectangle.
  • drawRectBaseRatio
    Draw the outline of the specified rectangle. The logical coordinates are proportional to the base co
  • drawTextBaseRatio
    Draw a string with given rotation angle. Reference point is the center of string. The logical coordi
  • fillPolygon
    Fill polygon. The coordinates are in logical coordinates.
  • drawTextBaseRatio,
  • fillPolygon,
  • fillRect,
  • fillRectBaseRatio,
  • getColor,
  • getFont,
  • getLowerBound,
  • getStroke,
  • getUpperBound,
  • rotate

Popular in Java

  • Parsing JSON documents to java classes using gson
  • runOnUiThread (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getApplicationContext (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now