Skip to Main Content

Graphics Draw a curce arrow icon

800414Jun 5 2010 — edited Jun 14 2010
can i help me locate the arrow head in to top right ARC
this is what i have so far

thank you
package org.jtpc.gui.icons;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.awt.geom.AffineTransform;



public class IconRotateRight implements Icon{

  private int m_size = 20;

  public IconRotateRight(int size){
     m_size = size;
  }
  
  public int getIconHeight(){
    return m_size;
  }

  public int getIconWidth(){
    return m_size;
  }

  public void paintIcon(Component c, Graphics g, int x, int y){
    Graphics2D g2 = (Graphics2D)g;
    Object hintOriginal = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 
    
    int strokeSize = m_size/6;
    
    Stroke strokeOriginal = g2.getStroke();
    g2.setStroke(new BasicStroke(strokeSize ,BasicStroke.CAP_SQUARE,BasicStroke.JOIN_MITER));
    
    g2.drawArc(x+(strokeSize/2), y+(strokeSize/2), m_size-(strokeSize*2), m_size-(strokeSize*2), 45, 180);

    g2.setStroke(strokeOriginal);

    
    
    int arrSize = (m_size/4) + strokeSize;
    int[] xArr = new int[3];
    int[] yArr = new int[3];

    xArr[0] = x+(strokeSize/2);
    xArr[1] = x +(strokeSize/2)+ arrSize;
    xArr[2] = x +(strokeSize/2)+ (arrSize/2);

    yArr[0] = y+(strokeSize/2);
    yArr[1] = y+(strokeSize/2);
    yArr[2] = y+(strokeSize/2) - (arrSize/2);


    AffineTransform  origXform = g2.getTransform();
    AffineTransform newXform  = (AffineTransform)(origXform.clone());
    
    int anchorX = (x+(strokeSize/2))  + (m_size-(strokeSize*2))/2;
    int anchorY = (y+(strokeSize/2))  + (m_size-(strokeSize*2))/2;

    anchorX = anchorX + (m_size/8);
    anchorY = anchorY - (m_size/8);
    
    newXform.rotate(Math.toRadians(135) ,anchorX ,anchorY);
    g2.setTransform(newXform);

    g2.fillPolygon(xArr ,yArr ,3);
    
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, hintOriginal);
  }
  
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on Jul 12 2010
Added on Jun 5 2010
5 comments
781 views