Package java.awt.geom

Examples of java.awt.geom.Rectangle2D


         }

         Component headerComp = headerRenderer.getTableCellRendererComponent(getTable(), null, false, false, 0, colIx);
         FontMetrics headerFontMetrics = headerComp.getFontMetrics(headerComp.getFont());

         Rectangle2D bounds = headerFontMetrics.getStringBounds("" + column.getHeaderValue(), headerComp.getGraphics());

         newWidth = Math.max(newWidth, bounds.getBounds().width);
      }



      if(0 == rowCount)
      {
         if(includeColHeaders)
         {
            getColumnModel().getColumn(colIx).setPreferredWidth(newWidth + 10);
            //getTable().doLayout();
         }

         return;
      }


      TableCellRenderer cellRenderer = getTable().getCellRenderer(0, colIx);
      Component cellComp = cellRenderer.getTableCellRendererComponent(getTable(), null, false, false, rowCount - 1, colIx);
      FontMetrics cellFontMetrics = cellComp.getFontMetrics(cellComp.getFont());


      for (int i = 0; i < rowCount; i++)
      {
         Object value = getTable().getModel().getValueAt(i, modelIx);

         String stringVal = "";
         if( getTable().getCellRenderer(i,colIx) instanceof SquirrelTableCellRenderer)
         {
            stringVal += ((SquirrelTableCellRenderer)getTable().getCellRenderer(i,colIx)).renderValue(value);
         }
         else
         {
            stringVal += value;
         }

         Rectangle2D bounds = cellFontMetrics.getStringBounds(stringVal, cellComp.getGraphics());

         newWidth = Math.max(newWidth, bounds.getBounds().width);
      }

      getColumnModel().getColumn(colIx).setPreferredWidth(newWidth + 10);
      //getTable().doLayout();
   }
View Full Code Here


    final Dimension maxSize = new Dimension(0, 0);
    for (int i = 0; i < btns.length; ++i)
    {
      final JButton btn = btns[i];
      final FontMetrics fm = btn.getFontMetrics(btn.getFont());
      Rectangle2D bounds = fm.getStringBounds(btn.getText(), btn.getGraphics());
      int boundsHeight = (int) bounds.getHeight();
      int boundsWidth = (int) bounds.getWidth();
      maxSize.width = boundsWidth > maxSize.width ? boundsWidth : maxSize.width;
      maxSize.height = boundsHeight > maxSize.height ? boundsHeight : maxSize.height;
    }

    Insets insets = btns[0].getInsets();
View Full Code Here

          document.closeElement();
          continue;
        }

        // Calculate label width, left and top:
        Rectangle2D textBox = textService.getStringBounds(labelString, labelStyle.getFontStyle());
        int boxWidth = (int) textBox.getWidth() + 8; // TODO: check why not wide enough !!!
        int boxHeight = (int) textBox.getHeight() + 2;
        int left = ((int) labelPos.getX()) - boxWidth / 2;
        int top = ((int) labelPos.getY()) - boxHeight / 2;

        // Group for an individual label (vml:group):
        document.writeElement("vml:group", true);
View Full Code Here

          String labelString = feature.getLabel();
          if (null != labelString && labelString.length() > 0) {
            labelPos = (Point) transformer.transform(p);
            boolean createChild = true;

            Rectangle2D textBox = textService.getStringBounds(labelString, labelStyle.getFontStyle());
            document.writeElement("rect", createChild);
            document.writeAttribute("id", feature.getId() + ".lblBG");
            document.writeAttribute("x", labelPos.getX() - Math.round(textBox.getWidth() / 2));
            document.writeAttribute("y", labelPos.getY() - Math.round(textBox.getHeight()));
            document.writeAttribute("width", Math.round(textBox.getWidth()));
            document.writeAttribute("height", Math.round(textBox.getHeight()));
            document.writeAttribute("style", getCssStyle(bgStyle));
            createChild = false;

            // Text:
            document.writeElement("text", createChild);
            document.writeAttribute("id", feature.getId() + ".lblTXT");
            document.writeAttribute("x", labelPos.getX());
            // pull up baseline position to accommodate for descent
            document.writeAttribute("y", labelPos.getY() - Math.round(textBox.getMaxY()));
            // TODO: config option, center label
            document.writeAttribute("text-anchor", "middle");
            document.writeAttribute("style", getCssStyle(labelStyle.getFontStyle()));
            document.writeTextNode(labelString);
          }
View Full Code Here

   */
  protected void evaluateRenderer(byte evaluation) throws JRException
  {
    JFreeChart chart = evaluateChart(evaluation);
   
    Rectangle2D rectangle = new Rectangle2D.Double(0,0,getWidth(),getHeight());

    renderer =
      ChartUtil.getChartRendererFactory(getRenderType()).getRenderer(
        chart,
        chartHyperlinkProvider,
View Full Code Here

  private void drawText(Graphics2D gr, String text, int size, Color color, int iconSize) {
    int max = iconSize - 1;
    TextLayout tl = new TextLayout(text, gr.getFont(), gr.getFontRenderContext());
    gr.setColor(TEXTBACKGROUND);
    gr.setStroke(new BasicStroke());
    Rectangle2D b = tl.getBounds();
    b = new Rectangle2D.Double(0, max, b.getWidth() + 1, b.getHeight() + 1);
    gr.fill(b);
    gr.setColor(color);
    gr.setFont(new Font("SansSerif", Font.PLAIN, size));
    gr.drawString(text, 1, max);
  }
View Full Code Here

   */
  public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
      Rectangle2D view) {

    g2.setStroke(new BasicStroke(1.0f));
    Rectangle2D lengthRect = DialPlot.rectangleByRadius(frame,
        this.getRadius(), this.getRadius());
    Rectangle2D widthRect = DialPlot.rectangleByRadius(frame,
        this.getWidthRadius(), this.getWidthRadius());
    double value = ChartThemesUtilities.getScaledValue(plot.getValue(this.getDatasetIndex()), scale);
    DialScale scale = plot.getScaleForDataset(this.getDatasetIndex());
    double angle = scale.valueToAngle(value);

View Full Code Here

   */
  public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
      Rectangle2D view) {

    // work out the anchor point
    Rectangle2D f = DialPlot.rectangleByRadius(frame, getRadius(),
        this.getRadius());
    Arc2D arc = new Arc2D.Double(f, this.getAngle(), 0.0, Arc2D.OPEN);
    Point2D pt = arc.getStartPoint();

    // calculate the bounds of the template value
    FontMetrics fm = g2.getFontMetrics(this.getFont());
    String s = this.getNumberFormat().format(this.getTemplateValue());
    Rectangle2D tb = TextUtilities.getTextBounds(s, g2, fm);

    // align this rectangle to the frameAnchor
    Rectangle2D bounds = RectangleAnchor.createRectangle(new Size2D(
        tb.getWidth(), tb.getHeight()), pt.getX(), pt.getY(),
        this.getFrameAnchor());

    // add the insets
    Rectangle2D fb = this.getInsets().createOutsetRectangle(bounds);

    // draw the background
    g2.setPaint(this.getBackgroundPaint());
    g2.fill(fb);

View Full Code Here

   *     permitted).
   */
  public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
      Rectangle2D view) {
   
    Rectangle2D arcRect = DialPlot.rectangleByRadius(frame,
        this.getTickRadius(), this.getTickRadius());
    Rectangle2D arcRectMajor = DialPlot.rectangleByRadius(frame,
        this.getTickRadius() - this.getMajorTickLength(),
        this.getTickRadius() - this.getMajorTickLength());
    Rectangle2D arcRectMinor = arcRect;
    if (this.getMinorTickCount() > 0 && this.getMinorTickLength() > 0.0) {
      arcRectMinor = DialPlot.rectangleByRadius(frame,
          this.getTickRadius() - this.getMinorTickLength(),
          this.getTickRadius() - this.getMinorTickLength());
    }
    Rectangle2D arcRectForLabels = DialPlot.rectangleByRadius(frame,
        this.getTickRadius() - this.getTickLabelOffset(),
        this.getTickRadius() - this.getTickLabelOffset());
   
    boolean firstLabel = true;
   
View Full Code Here

   * @param view  the dial's view rectangle (in Java2D space).
   */
  public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
      Rectangle2D view) {
   
    Rectangle2D arcRectInner = DialPlot.rectangleByRadius(frame,
        this.getInnerRadius(), this.getInnerRadius());
    Rectangle2D arcRectOuter = DialPlot.rectangleByRadius(frame,
        this.getOuterRadius(), this.getOuterRadius());
   
    DialScale scale = plot.getScale(this.getScaleIndex());
    if (scale == null) {
      throw new RuntimeException("No scale for scaleIndex = "
View Full Code Here

TOP

Related Classes of java.awt.geom.Rectangle2D

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.