IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

2D Java Discussion :

Colorier un cercle avec des droites


Sujet :

2D Java

  1. #1
    Membre régulier
    Inscrit en
    Mars 2005
    Messages
    162
    Détails du profil
    Informations forums :
    Inscription : Mars 2005
    Messages : 162
    Points : 70
    Points
    70
    Par défaut Colorier un cercle avec des droites
    Bonjour.

    Je viens de réussir à faire un camembert maison, et maintenant, je voudrais lui donner des couleurs!

    Mon camembert est dessiné à partir d'un vecteur contenant des budgets. La somme de tous les budgets me donne le camembert en entier, comme tout le monde l'a compris ^^.

    Alors, comment ai-je fait mon camembert maison? Et bien j'ai commencé par tracer un beau cercle. Ensuite, si le nombre de part est au moins de deux, je découpe un premier rayon.

    A partir de là, je fais une boucle sur chaque valeur de mon vecteur.
    Pour chaque valeur, je calcul l'angle de la part qu'elle va occuper dans le camembert, puis je calcule l'angle déjà rempli depuis le départ. c'est avec cet angle que je dessine les droites délimitant les parts.
    Je voudrais donc savoir comment il serait possible de dessiner chaque nouvelle part. On a les coordonnées du point de fin et de début de la part, ca doit donc être faisable!

    Concernant la colorisation, le principe est simple: un tableau color_camembert est initialisé avec 100 couleurs, et pour chaque part i, on lui attribut la i-ème couleur du tableau.

    Quelqu'un a-t-il un moyen de dessiner mes parts?
    J'ai 2 propositions, mais je ne sais pas les mettre en oeuvre: première: je trace un triangle avec comme donnée 2 droite, un sommet. je le délimite par l'arc de cercle....

    Sinon, je trace une infinité de droite entre mes 2 points, ce qui remplit mon triangle...

    Après, si ca se fait ou pas, à vous de me le dire

    Merci ^^
    Qui osera affronter ma brute??
    Si tu perds, rejoins mon clan

  2. #2
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 846
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 846
    Points : 22 851
    Points
    22 851
    Billets dans le blog
    51
    Par défaut
    Houla que de complications pour pas grand chose. Il existe en Java2D un objet qui va t'etre fort utile : Arc2D et ses implementations concretes : Arc2D.Double et Arc2D.Float. Tout le reste n'est que l'affaire d'une regle de trois pour le calcul de l'angle de depart et de l'angle de fin de l'arc et l'utilisation judicieuse des methodes fill() et draw() de la classe Graphics/Graphics2D.

    Si vraiment tu veux faire un hachurage (et non pas un remplissage plein comme tu sembles l'indiquer), tu as deux solutions :
    - creer un TexturePaint qui dessine quelques droites // et utiliser ce TexturePaint pour faire un fill() de l'arc.
    - mettre la zone de clip sur la forme de l'arc et dessiner tout un tas de droites // jusqu'a remplir la boite englobante (getBoundingBox()) de l'arc
    ...

    Voir le pacman qui est dans la demo Java2Demo qui se trouve dans le repertoire demo/jfc/java2D fournie avec le JDK (onglet Arcs_Curves). Les autres onglet te donneront egalement peut-etre quelques idee (nottament sur l'usage des textures et des gradients).
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  3. #3
    Membre régulier
    Inscrit en
    Mars 2005
    Messages
    162
    Détails du profil
    Informations forums :
    Inscription : Mars 2005
    Messages : 162
    Points : 70
    Points
    70
    Par défaut
    Pourquoi suis-je un noob?

    Encore un aprem de perdu pour des conneries!

    merci pour le lien, je vais tester ca tout de suite
    Qui osera affronter ma brute??
    Si tu perds, rejoins mon clan

  4. #4
    Membre régulier
    Inscrit en
    Mars 2005
    Messages
    162
    Détails du profil
    Informations forums :
    Inscription : Mars 2005
    Messages : 162
    Points : 70
    Points
    70
    Par défaut
    Mais c'est tendu ce truc je dirais!!!


    Pour le moment, j'en suis là:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    public void paint(Graphics g) {
     
    	// Tableau des couleurs mis à l'arrache ici pour tester
    	Color[] tableColor = new Color[100];
    	tableColor[0] = new Color(100);
    	tableColor[1] = new Color(500);
    	tableColor[2] = new Color(105);
    	tableColor[3] = new Color(150);
    	tableColor[4] = new Color(440);
    	tableColor[5] = new Color(777);
    	tableColor[6] = new Color(268);
    	tableColor[7] = new Color(631);
    	tableColor[8] = new Color(237);
    	tableColor[9] = new Color(001);
    	tableColor[10] = new Color(010);
    	tableColor[11] = new Color(070);
    	tableColor[12] = new Color(162);
     
    	//le nombre de budgets dans notre vecteur
    	int nbBudgets=budget.getListeCategorie().size();
    	// Le montant du bugdet i du vecteur
    	double montantBudget=0;
    	// L'intitule du budget i du vecteur
    	String nomBudget = null;
    	//La somme des budgets dans le vecteur
    	double montantTotal = 0;
    	// l'angle de la proportion du budget par rapport au budget total
    	double angleBudget = 0;
    	// L'angle parcouru depuis le depart du dessinage du camembert
    	double angleTotal = 0;
     
    	Graphics2D g2D = (Graphics2D) g;
    	Rectangle2D cam = new Rectangle2D.Double(200,200,250, 150);
    	Arc2D.Double camembert;
     
    	for (int i=0;i< nbBudgets;i++){
    		montantTotal += budget.retourneCategorie(i).getMontantPrevisionnel();
    	}
     
    	for (int i=0;i< nbBudgets;i++){
    		nomBudget=budget.retourneCategorie(i).getNom();
    		montantBudget=budget.retourneCategorie(i).getMontantPrevisionnel();
    		angleBudget = (360 * montantBudget / montantTotal);
    		camembert = new Arc2D.Double(cam, angleTotal,angleBudget, Arc2D.Double.PIE);
     
    		angleTotal += angleBudget;
     
    	}
    }
    }

    Rien ne s'affiche, je ne sais pas si ca va compléter mon dessin au fur et à mesure où si ca va dessiner tout proprement, je ne sais pas si où affecter la couleur... sinon tout va bien

    Un peu d'aide s'il vous plait ^^?
    Qui osera affronter ma brute??
    Si tu perds, rejoins mon clan

  5. #5
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 846
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 846
    Points : 22 851
    Points
    22 851
    Billets dans le blog
    51
    Par défaut
    Code Java : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    package test;
     
    import java.awt.*;
    import java.awt.geom.*;
    import java.util.*;
    import javax.swing.*;
     
    /**
     * <p>Title: </p>
     *
     * <p>Description: </p>
     *
     * <p>Copyright: Copyright (c) 2006</p>
     *
     * <p>Company: </p>
     *
     * @author not attributable
     * @version 1.0
     */
    public class TestPie extends JPanel {
      /** Shared color array.
       */
      private static final Color[] TABLE_COLOR = new Color[12];
     
      /** Static initializer.
       */
      static {
        TABLE_COLOR[0] = new Color(100);
        TABLE_COLOR[1] = new Color(500);
        TABLE_COLOR[2] = new Color(105);
        TABLE_COLOR[3] = new Color(150);
        TABLE_COLOR[4] = new Color(440);
        TABLE_COLOR[5] = new Color(777);
        TABLE_COLOR[6] = new Color(268);
        TABLE_COLOR[7] = new Color(631);
        TABLE_COLOR[8] = new Color(237);
        TABLE_COLOR[9] = new Color(001);
        TABLE_COLOR[10] = new Color(010);
        TABLE_COLOR[11] = new Color(070);
      }
     
      /** Shared stroke.
       */
      private static final Stroke STROKE = new BasicStroke(1f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
     
      /** List of values.
       */
      private java.util.List<Number> valueList;
      /** Sum of values.
       */
      private double sum = 0;
     
      /** Re-usable arc.
       */
      private Arc2D.Double arc = new Arc2D.Double();
     
      /** Creates a new instance.
       * @param values Initial values.
       */
      public TestPie(Number ...values) {
        super();
        arc.setArcType(Arc2D.PIE);
        valueList = Arrays.asList(values);
        //Calculate sum.
        for (Number value : values) {
          sum += value.doubleValue();
        }
      }
     
      /**
       * {@inheritDoc}
       */
      @Override protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Dimension size = getSize();
        Insets insets = getInsets();
        // Get past (optional) panel border.
        int width = size.width - (insets.left + insets.right);
        int height = size.height - (insets.top + insets.bottom);
        double diameter = Math.min(width, height) - 5;
        // Don't bother if too small to draw.
        if (diameter > 0) {
          arc.setFrame(insets.left + (width - diameter) / 2.0, insets.top + (height - diameter) / 2.0, diameter, diameter);
          double theta = 0;
          double extend = 0;
          Graphics2D g2d = (Graphics2D) g;
          g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
          g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
          // XOR does not like antialiased text.
          g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
          int i = 0;
          for (Number value : valueList) {
            extend = 360 * value.doubleValue() / (double) sum;
            arc.setAngleStart(theta);
            arc.setAngleExtent(extend);
            Color color = TABLE_COLOR[i];
            g2d.setPaint(color);
            g2d.fill(arc);
            g2d.setStroke(STROKE);
            g2d.setPaint(getForeground());
            g2d.draw(arc);
            // The following is just for debugging purpose.
            // If the arc is too narrowed, the label may be coverred by the next pie slice.
            // Ideally, you would make two separate loops :
            // 1st loop - calculate, fill, draw pie slices.
            // 2nd loop - draw labels ontop of chart
            Area area = new Area(arc);
            Rectangle bounds = area.getBounds();
            g2d.setXORMode(Color.WHITE);
            g2d.drawString(String.valueOf(value) + " (" + i + ")", bounds.x + bounds.width / 2f, bounds.y + bounds.height / 2f);
            g2d.setPaintMode();
            theta += extend;
            i++;
          }
        }
      }
     
      /** Self-testing main.
       * @param args Arguments from the command-line.
       */
      public static void main(String ...args) {
        // Start at EDT.
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            TestPie testPie = new TestPie(20, 15, 50, 35, 5, 20);
            JFrame frame = new JFrame("Test");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setLayout(new BorderLayout());
            frame.add(testPie, BorderLayout.CENTER);
            frame.setSize(320, 200);
            frame.setVisible(true);
          }
        });
      }
    }

    Il faut se souvenir que Arc2D marche avec des degres et non pas des radians (c'est dans la doc. Oui je trouve ca stupide moi aussi car ailleur on manipule les angles en radian mais c'est lie au fait qu'historiquement dans Java 1.0 on dessine les arc avec de angles en degres...)
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  6. #6
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 846
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 846
    Points : 22 851
    Points
    22 851
    Billets dans le blog
    51
    Par défaut
    Tiens en voila un autre qui reagit en plus a la souris et avec des labels mieux places, histoire de te donner des idees :

    Code JAVA : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    package test;
     
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    import java.awt.font.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
     
    /**
     * <p>Title: </p>
     *
     * <p>Description: </p>
     *
     * <p>Copyright: Copyright (c) 2006</p>
     *
     * <p>Company: </p>
     *
     * @author not attributable
     * @version 1.0
     */
    public class TestPie extends JPanel implements ComponentListener, MouseInputListener {
      private static final double PI_2 = 2 * Math.PI;
     
      /** Shared color array.
       */
      private static final Color[] TABLE_COLOR = new Color[12];
     
      /** Static initializer.
       */
      static {
        TABLE_COLOR[0] = new Color(100);
        TABLE_COLOR[1] = new Color(500);
        TABLE_COLOR[2] = new Color(105);
        TABLE_COLOR[3] = new Color(150);
        TABLE_COLOR[4] = new Color(440);
        TABLE_COLOR[5] = new Color(777);
        TABLE_COLOR[6] = new Color(268);
        TABLE_COLOR[7] = new Color(631);
        TABLE_COLOR[8] = new Color(237);
        TABLE_COLOR[9] = new Color(001);
        TABLE_COLOR[10] = new Color(010);
        TABLE_COLOR[11] = new Color(070);
      }
     
      /** Shared stroke.
       */
      private static final Stroke DEFAULT_STROKE = new BasicStroke(1f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
     
      /** Shared stroke.
       */
      private static final Stroke SELECTED_STROKE = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
     
      private static final Font DEFAULT_FONT = new Font("Dialog", Font.PLAIN, 10);
     
      /** List of values.
       */
      private java.util.List<Number> valueList;
      /** Sum of values.
       */
      private double sum = 0;
     
      private Arc2D selectedArc = null;
      private java.util.List<Arc2D> shapeList;
      private Map<Arc2D, Number> arcToValueMap = new HashMap<Arc2D, Number>();
     
      /** Creates a new instance.
       * @param values Initial values.
       */
      public TestPie(Number ...values) {
        super();
        valueList = Arrays.asList(values);
        //Calculate sum.
        for (Number value : values) {
          sum += value.doubleValue();
        }
        shapeList = new ArrayList<Arc2D>(values.length);
        for (int i = 0; i < values.length; i++) {
          Arc2D arc = new Arc2D.Double();
          arc.setArcType(Arc2D.PIE);
          shapeList.add(arc);
          arcToValueMap.put(arc, values[i]);
        }
        addComponentListener(this);
        addMouseListener(this);
        addMouseMotionListener(this);
      }
     
      private void calculateShape() {
        Dimension size = getSize();
        Insets insets = getInsets();
        // Get past (optional) panel border.
        int width = size.width - (insets.left + insets.right);
        int height = size.height - (insets.top + insets.bottom);
        double diameter = Math.min(width, height) - 5;
        // Don't bother if too small to draw.
        if (diameter > 0) {
          double theta = 0;
          double extend = 0;
          for (int i = 0; i < valueList.size(); i++) {
            Arc2D arc = shapeList.get(i);
            Number value = valueList.get(i);
            arc.setFrame(insets.left + (width - diameter) / 2.0, insets.top + (height - diameter) / 2.0, diameter, diameter);
            extend = 360 * value.doubleValue() / (double) sum;
            arc.setAngleStart(theta);
            arc.setAngleExtent(extend);
            theta += extend;
          }
        }
     
      }
     
      /**
       * {@inheritDoc}
       */
      @Override protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Dimension size = getSize();
        Insets insets = getInsets();
        // Get past (optional) panel border.
        int width = size.width - (insets.left + insets.right);
        int height = size.height - (insets.top + insets.bottom);
        double diameter = Math.min(width, height) - 5;
        // Don't bother if too small to draw.
        if (diameter > 0) {
          Graphics2D g2d = (Graphics2D) g;
          g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
          g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
          // XOR does not like antialiased text.
          g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
          for (int i = 0; i < valueList.size(); i++) {
            Arc2D arc = shapeList.get(i);
            Color color = TABLE_COLOR[i];
            g2d.setPaint(color);
            g2d.fill(arc);
            if (arc != selectedArc) {
              g2d.setStroke(DEFAULT_STROKE);
              g2d.setPaint(getForeground());
              g2d.draw(arc);
            }
          }
          // Draw selection.
          if (selectedArc != null) {
            g2d.setStroke(SELECTED_STROKE);
            g2d.setPaint(getForeground().brighter().brighter());
            g2d.draw(selectedArc);
          }
          // Draw labels.
          double labelPosition = 2 / 3.0 * diameter / 2.0;
          g2d.setPaint(getForeground());
          for (int i = 0; i < valueList.size(); i++) {
            Arc2D arc = shapeList.get(i);
            Number value = valueList.get(i);
            double theta = arc.getAngleStart() + arc.getAngleExtent() / 2.0;
            theta = PI_2 * theta / 360.0;
            double x = insets.left + width / 2.0 + labelPosition * Math.cos(theta);
            double y = insets.top + height / 2.0 + labelPosition * Math.sin( -theta);
            Font font = DEFAULT_FONT;
            if (arc == selectedArc) {
              font = font.deriveFont(14f);
            }
            String label = String.valueOf(value) + " (" + i + ")";
            Rectangle2D stringBounds = font.getStringBounds(label, g2d.getFontRenderContext());
            LineMetrics lineMetrics = font.getLineMetrics(label, g2d.getFontRenderContext());
            g2d.setFont(font);
            g2d.setXORMode(Color.WHITE);
            g2d.drawString(label, (float) (x - stringBounds.getWidth() / 2.0), (float) (y + lineMetrics.getAscent() / 2.0));
            g2d.setPaintMode();
          }
        }
      }
     
      /**{@inheritDoc}
       */
      public void componentResized(ComponentEvent event) {
        calculateShape();
        repaint();
      }
     
      /**{@inheritDoc}
       */
      public void componentMoved(ComponentEvent event) {
     
      }
     
      /**{@inheritDoc}
       */
      public void componentShown(ComponentEvent event) {
     
      }
     
      /**{@inheritDoc}
       */
      public void componentHidden(ComponentEvent event) {
     
      }
     
     
      /**{@inheritDoc}
       */
      public void mouseClicked(MouseEvent event) {
     
      }
     
     
      /**{@inheritDoc}
       */
      public void mousePressed(MouseEvent event) {
     
      }
     
     
      /**{@inheritDoc}
       */
      public void mouseReleased(MouseEvent event) {
     
      }
     
     
      /**{@inheritDoc}
       */
      public void mouseEntered(MouseEvent event) {
     
      }
     
     
      /**{@inheritDoc}
       */
      public void mouseExited(MouseEvent event) {
     
      }
     
      /**{@inheritDoc}
       */
      public void mouseDragged(MouseEvent event) {
     
      }
     
      /**{@inheritDoc}
       */
      public void mouseMoved(MouseEvent event) {
        selectedArc = null;
        String tooltip = null;
        for (Arc2D arc : shapeList) {
          if (arc.contains(event.getX(), event.getY())) {
            selectedArc = arc;
            Number value = arcToValueMap.get(arc);
            tooltip = String.valueOf(value);
            break;
          }
        }
        setToolTipText(tooltip);
        repaint();
      }
     
      /** Self-testing main.
       * @param args Arguments from the command-line.
       */
      public static void main(String ...args) {
        // Start at EDT.
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            TestPie testPie = new TestPie(20, 15, 50, 35, 5, 20);
            JFrame frame = new JFrame("Test");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setLayout(new BorderLayout());
            frame.add(testPie, BorderLayout.CENTER);
            frame.setSize(320, 200);
            frame.setVisible(true);
          }
        });
      }
    }
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  7. #7
    Membre régulier
    Inscrit en
    Mars 2005
    Messages
    162
    Détails du profil
    Informations forums :
    Inscription : Mars 2005
    Messages : 162
    Points : 70
    Points
    70
    Par défaut
    Merci pour tout, vraiment niquel, j'ai adapté le testPie à mes besoins, niquel!!!
    Qui osera affronter ma brute??
    Si tu perds, rejoins mon clan

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Comment créer un utilisateurs avec des droits très limités
    Par M@XflY dans le forum Administration système
    Réponses: 2
    Dernier message: 09/12/2008, 19h37
  2. Réponses: 20
    Dernier message: 29/02/2008, 22h17
  3. Interface Utilisateur avec des droits
    Par Karibbean971 dans le forum Delphi
    Réponses: 5
    Dernier message: 18/09/2006, 16h30
  4. Réponses: 2
    Dernier message: 08/05/2006, 21h08
  5. Utiliser MySqlAdmin avec des droits utilisateurs sur XP
    Par thorgal85 dans le forum Outils
    Réponses: 2
    Dernier message: 18/03/2005, 12h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo