• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to implement this structure?

 
Greenhorn
Posts: 20
jQuery Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!
I'm trying to implement a simply java image editor, but i can't find a good solution!
So, i have an interface PICTURE with some methods. PNG, GIF etc implements Picture interface.
Now i want a PNGEDITOR that can work on PNG type. And the same for other formats.
I have tryed different patterns but is not working.
Any idea how can i arrange this?
Thank you
 
Michael Lars
Greenhorn
Posts: 20
jQuery Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
? anyone ?
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Lars wrote:? anyone ?


<comment removed>

If it was me, I'd probably look to have PngEditor (and classes should be named that way, not in all-caps) implement a generalized Editor or ImageEditor interface. Then your Picture deals with an Editor, which you can specify at implementation time.

That said, we'll need a lot more information if we're to help you much further.

Winston
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:Michael, you should EaseUp (←click)...


Michael,

My apologies. It was pointed out by a colleague that there was two weeks between your posts (I didn't look properly, and assumed they were from the same day), and that does seem fair to query.

I've removed the offending comment but left it here for posterity.

Winston
 
Michael Lars
Greenhorn
Posts: 20
jQuery Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, sorry for the caps lock.

All I want is to connect this two diagrams.

Thanks!
img.png
[Thumbnail for img.png]
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Lars wrote:All I want is to connect this two diagrams.


What? Figuratively or literally?

If you actually want to join two images together than I suspect that your editor has to have a 'join' or 'paste' function. If, given an image of a particular type, you simply want to launch the correct Editor class, then you need something to "know" which one to choose. If you can't edit the image class itself, then you'll need to either:
(a) Wrap it, or
(b) Write a 3rd-party class (or perhaps an enum) that can do the translation.

Winston
 
Michael Lars
Greenhorn
Posts: 20
jQuery Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actually I want that the PngEditor can "use/work" only the concrete Png Class, and the same for the other. This have to be extensible because i have a lot types of "Images".
Does the abstract pattern work in this case?!
Thanks!
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Lars wrote:actually I want that the PngEditor can "use/work" only the concrete Png Class, and the same for the other. This have to be extensible because i have a lot types of "Images".
Does the abstract pattern work in this case?!


I think you mean the abstract factory pattern; and yes, it could work providing all your Editors implement the same interface (ImageEditor?).

As to extensible: is an enum 'extensible' enough? If I couldn't actually put that knowledge in the image class itself, it's probably the way I'd do it - ie, have an enum value for each image type that knows what its Editor is - at least on my first cut.

Winston
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic