Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to implement this structure?

 
Michael Lars
Greenhorn
Posts: 20
Java jQuery Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Java jQuery Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
? anyone ?
 
Winston Gutkowski
Bartender
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Java jQuery Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Java jQuery Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic