Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Eclipse PaperClip vs Google PaperClip(Which one to choose)
Eclipse PaperClip vs Google PaperClip [message #651634] Tue, 01 February 2011 00:14 Go to next message
tenor  is currently offline tenor Friend
Messages: 57
Registered: October 2010
Member
Hi,

Among the two paperclip ie google and eclipse ,as a beginner which one i should choose and why?

Any working example (snippet) of Google one as is there for eclipse.

Thanks.
Re: Eclipse PaperClip vs Google PaperClip [message #653031 is a reply to message #651634] Tue, 08 February 2011 04:53 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
Except for the package names they are functionally the same.

All maintenance going forward will happen at Eclipse.org however.

Matthew

On 01/31/2011 05:14 PM, tenor wrote:
> Hi,
>
> Among the two paperclip ie google and eclipse ,as a beginner which one i
> should choose and why?
>
> Any working example (snippet) of Google one as is there for eclipse.
>
> Thanks.
Re: Eclipse PaperClip vs Google PaperClip [message #653071 is a reply to message #653031] Tue, 08 February 2011 11:01 Go to previous messageGo to next message
tenor  is currently offline tenor Friend
Messages: 57
Registered: October 2010
Member

public Print printImage() {
// Image image = null;
int h =0;
int w = 0;
GC gc = null;
//GraphicalViewer graphicalViewer = null;
GraphicalViewer graphicalViewer = new ScrollingGraphicalViewer();
ScalableFreeformRootEditPart rootEditPart =
(ScalableFreeformRootEditPart)
graphicalViewer.getEditPartRegistry().get(LayerManager.ID);
graphicalViewer.setEditDomain(new DefaultEditDomain(null));
graphicalViewer.setRootEditPart(new ScalableFreeformRootEditPart());
graphicalViewer.setEditPartFactory(new MYEditPartFactory(context));
graphicalViewer.setContents(getContents());
graphicalViewer.flush();
IFigure rootFigure = ((LayerManager)
rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
// rootFigure.add(new TLDSatellitePart());
Printer printer = new Printer(new PrinterData());
DefaultGridLook look = new DefaultGridLook();
look.setCellBorder(new LineBorder());
GridPrint grid = new GridPrint(look);
IFigure topFigure = new Figure();
//topFigure.add(new MYLoadingFigure());
topFigure.add(new MYEditPartFactory(context))
//Rectangle r = topFigure.getBounds().getCopy();
Rectangle r = rootFigure.getBounds().getCopy();
//h = r.height;
//w = r.width;
w = topFigure.getBounds().width;
h = topFigure.getBounds().height;
/*h = 10;
w= 20;*/
Image image = new Image(printer, w, h);
//Image image = new Image(printer,r.getSize().width, r.getSize().height);

gc = new GC(image);
//gc.drawRectangle(0, 0, 50, 70);
SWTGraphics g = new SWTGraphics(gc);
//g.translate(r.x * -1, r.y * -1);
g.translate(w -1, h -1);

topFigure.paint(g);
grid.add(new ImagePrint(image.getImageData()));

// grid.add( new ImagePrint(imageData));

//return new BigPrint(grid);

return new BigPrint(grid);
}
I get exception as

java.lang.ClassCastException: org.eclipse.gef.editparts.ScalableRootEditPart cannot be cast to org.eclipse.gef.editparts.ScalableFreeformRootEditPart

My Qs are

1) Is it the right way of getting IFigure and hooking to GEF piece of code through, MYEditPartFactory, as i have seen
in PrintLogicExample of GEF.

2) is paperclip suited for printing GEF, if so, how.

3) How image is to be used? if i donot need to use image, ie want GEF screen to be printed to printer
can i do gc = new GC(printer) , donot think so, so , how to get gc ?

Ignore the comment out portion,as i earlier i tried for getting Ifigure but it was all null, during debug.

Hope to have EARLY reply. Smile
Re: Eclipse PaperClip vs Google PaperClip [message #653259 is a reply to message #653071] Wed, 09 February 2011 04:59 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
There was a question about this some time ago (back when the project was
still on Sourceforge). The solution:

http://sourceforge.net/tracker/index.php?func=detail&aid =1633591&group_id=148509&atid=771875

If you want to print a figure with higher fidelity, you'll need to
implement FigurePrint, FigureIterator and FigurePiece.

class FigurePrint implements Print {
private IFigure figure;

public FigurePrint(IFigure figure) {
this.figure = figure;
}

public PrintIterator iterator(Device device, GC gc) {
return new FigureIterator(figure, device, gc);
}
}

class FigureIterator implements PrintIterator {
public FigureIterator(IFigure figure, Device device, GC gc) {
...
}

...

public PrintPiece next(int width, int height) {
if (width and height big enough) {
return new FigurePiece(figure, device, gc);
}
}
}

class FigurePiece implements PrintPiece {
private SWTGraphics graphics;

public void paint(GC gc, int x, int y) {
if (graphics == null) {
graphics = new SWTGraphics(gc);
}

graphics.translate(x, y);

try {
figure.setSize(width, height);
figure.paint(graphics);
}
finally {
graphics.translate(-x, -y);
}
}

public void dispose() {
graphics.dispose();
}
}

Obviously there are several missing parts here that you will need to
fill in, but this should get you going.

One problem you may come across is that pixel density is much lower on a
monitor (typically 72DPI) vs printers which range between 300-600DPI, so
the lines in the figure may not scale relative to the font sizes.
Potentially you could get around this by calling graphics.scale()
instead of figure.setSize(), so that the whole figure scales.

Hope this helps,

Matthew
Re: Eclipse PaperClip vs Google PaperClip [message #655805 is a reply to message #653259] Tue, 22 February 2011 16:48 Go to previous messageGo to next message
tenor  is currently offline tenor Friend
Messages: 57
Registered: October 2010
Member
I have to print my application help page(RCP app).
If i have to use swt paperclips, how i should go about it, as help page might have image along with text.
ImagePrint and TextPrint both will be used at the same time?
Re: Eclipse PaperClip vs Google PaperClip [message #655892 is a reply to message #655805] Wed, 23 February 2011 05:26 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
On 02/22/2011 09:49 AM, tenor wrote:
> I have to print my application help page(RCP app).
> If i have to use swt paperclips, how i should go about it, as help page
> might have image along with text.
> ImagePrint and TextPrint both will be used at the same time?

Have you looked at the tutorials? They go into detail about how to
combine different prints into a layout.

http://code.google.com/p/swt-paperclips/wiki/Tutorials

Matthew
Re: Eclipse PaperClip vs Google PaperClip [message #655894 is a reply to message #655892] Wed, 23 February 2011 07:04 Go to previous messageGo to next message
tenor  is currently offline tenor Friend
Messages: 57
Registered: October 2010
Member
Hi,

Yes i have seen like

// Construct the header
GridPrint grid = new GridPrint("d:g, p");
grid.add(new TextPrint(title));
grid.add(new ImagePrint(logo));

But in help pages, which page will have screenshot or image at which exact location in page, how someone can know beforehand and i have to print text along with it.

Some psuedocode might help further.

Thanks.
Re: Eclipse PaperClip vs Google PaperClip [message #656087 is a reply to message #655894] Thu, 24 February 2011 04:17 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
I'm sorry, I'm not sure what it is you're asking me. Could you maybe
provide a mockup image to show the kind of layout you're looking for?

Matthew

On 02/23/2011 12:05 AM, tenor wrote:
> Hi,
>
> Yes i have seen like
>
> // Construct the header
> GridPrint grid = new GridPrint("d:g, p");
> grid.add(new TextPrint(title));
> grid.add(new ImagePrint(logo));
>
> But in help pages, which page will have screenshot or image at which
> exact location in page, how someone can know beforehand and i have to
> print text along with it.
>
> Some psuedocode might help further.
>
> Thanks.
Re: Eclipse PaperClip vs Google PaperClip [message #656303 is a reply to message #656087] Fri, 25 February 2011 00:10 Go to previous messageGo to next message
tenor  is currently offline tenor Friend
Messages: 57
Registered: October 2010
Member
http://img842.imageshack.us/i/helpprint.png/

http://img842.imageshack.us/i/helpprint.png/

I mean this kind of help pages where text and image both will be interspersed.

Much Thanks.

[Updated on: Fri, 25 February 2011 00:11]

Report message to a moderator

Re: Eclipse PaperClip vs Google PaperClip [message #656316 is a reply to message #656303] Fri, 25 February 2011 05:26 Go to previous message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
On 02/24/2011 05:10 PM, tenor wrote:
> I mean this kind of help pages where text and image both will be
> interspersed.
>
> Much Thanks.

I'm still not quite understanding what you're asking for, so I'll try
answering a couple ways:

If you want to intersperse text and images, you can just add alternating
TextPrint and ImagePrint instances to a single-column GridPrint.

GridPrint grid = new GridPrint("d:g");

grid.add(new TextPrint("text 1"));
grid.add(new ImagePrint(imageData1));

grid.add(new TextPrint("text 2));
grid.add(new ImagePrint(imageData2));

....etc

Whatever you add to the GridPrint, it will print it. Add as many rows
as you like.

If you're asking about where page breaks will happen--that's hard to
predict. In my experience you have often have to design your document
with a particular "reference" printer in mind, and tweak your document
layout until you get it to look right.

The only real control you have over page breaks is to add a BreakPrint
to your layout component (typically GridPrint) and let that serve as an
explicit page break.

Hope this helps,

Matthew
Previous Topic:Problem with CDateTime selection
Next Topic:XViewer in RCP View: got NoClassDefFoundError
Goto Forum:
  


Current Time: Mon Dec 22 00:50:54 GMT 2014

Powered by FUDForum. Page generated in 0.03402 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software