7 Replies Latest reply: Aug 3, 2010 9:00 AM by 800387 RSS

    a design problem

    843853
      In my application, I have to work with many symbols including point symbol, line symbol, fill symbol.
      I Set a abstract class as the parent of the PointSymbol,LIneSymbol and FillSymbol, however these symbole contain simple and comple.
      For example, a circle is a simple symbol, [ this|http://imagebin.org/107110] is a complex symbol , it is made up from the symbols.

      So how to design my symbol Architecture?

      I think my suitation like the Node very much.
      But I have no idea.
        • 1. Re: a design problem
          800387
          Sadly, that site is blocked for me at work, so I have no idea what the image contained. Your question, as written, is confusing. What is your actual issue?

          - Saish
          • 2. Re: a design problem
            843853
            For example, a symbols "○" is circle, it is a simple symbol.
            Symbol "◎" is a complex symbol, it can be made up by two simple symbole "○" with different size.

            So how to describe these relationship ?
            • 3. Re: a design problem
              800387
              Take a look here.

              - Saish
              • 4. Re: a design problem
                843853
                Thanks, I have read that paper,however my symbols I think is a Composite and a component at the sametime.

                So two methods:
                1) addSimple(), this is a typical composite method

                2)paint() getSize().. They are component method.

                How to handle this?

                I put these method under the Class SimpleSymbol directly, is it correct?
                • 5. Re: a design problem
                  800387
                  A composite is just shorthand for saying that an object can act as its own container for itself. java.awt.Component is an example of, well, a graphical component. java.awt.Container extends Component and can hold n components. It is therefore a composite.

                  I'm not sure why you are labeling some method names as "typical". I would declare paint() and getSize() as an interface Component that both SimpleSymbol and ComplexSymbol implement. However, only ComplexSymbol would have addSimple(Component).

                  - Saish
                  • 6. Re: a design problem
                    843853
                    Thanks , I got it.
                    Now,I use the following :
                    class SimpleSymbol{
                      int getSize();
                      void setSize(int size);
                      Color getFillColor();
                      void setFillColor(Color color);
                      ......
                      paint();
                    }
                    
                    class LayeredSymbol extends SimpleSymbol {
                      Arraylist<SimpleSymbol> childs=new Arraylist<SimpleSymbol>();
                      @Override
                      int getSize();
                      @Override
                      void setSize(int size);
                      @Override
                      Color getFillColor();
                      @Override  
                      void setFillColor(Color color);
                      ........................
                      @Override
                      paint() {
                        for(simpleSymbol s: childs) {
                          s.paint();
                        }
                      }
                    ........................
                    }
                    • 7. Re: a design problem
                      800387
                      Vintage composite in action. Love it. You might consider also adding an interface Symbol, but otherwise, it looks fine to me.

                      - Saish