Bug 132361 - Implement Pattern for ScaledGraphics
Summary: Implement Pattern for ScaledGraphics
Status: RESOLVED WORKSFORME
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.7.1 (Indigo) M7   Edit
Assignee: Lidija Grahek CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-17 12:02 EST by Joe Gee CLA
Modified: 2012-07-09 15:50 EDT (History)
9 users (show)

See Also:
ahunter.eclipse: galileo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joe Gee CLA 2006-03-17 12:02:03 EST
ScaledGraphics throws an exception when setting background patterns.  This causes problems for overview panes and zooming on diagrams.
Comment 1 Randy Hudson CLA 2006-03-17 13:02:02 EST
There is no way to scale a pattern, so the solution will not be in scaled graph, which does emulated scaling.

Thumbnail figure could take an option to use native vs. emulated scaling. Do you care to provide a patch?
Comment 2 Joe Gee CLA 2006-03-17 15:56:33 EST
That would leave the Scalable Panes still busted, right?
Comment 3 Randy Hudson CLA 2006-03-17 16:36:04 EST
Correct. So the best usage scenario would be to set emulated/native scaling on the GraphicalViewer using a viewer property. Then, the scalablerooteditpart and overview figure would both pick up that value somehow.
Comment 4 Joe Gee CLA 2006-03-22 12:22:09 EST
My boss finally okayed me to work on a patch for this, but not until after our product release in mid april.
Comment 5 Mark Levison CLA 2007-06-05 19:47:36 EDT
This bug seems to have gone nowhere. Currently I work around it by detecting whether I've got a ScalableEditPart and turning off the linear gradient fill.

What would it take to create a patch? Give me some idea and I will code it up.
Comment 6 Randy Hudson CLA 2007-06-07 09:49:04 EDT
Mark, see comment 3. The approach is not to change ScaledGraphics, but avoid its usage altogether.
Comment 7 Lidija Grahek CLA 2009-08-10 14:37:31 EDT
Question for Mark Gobeil: I noticed that in 267728 you added setBackgroundPattern() to ScaledGraphics in GEF. I assume that that resolves this defect? Also, please check 184651, I beleive that 267728 resolves that one too.
Comment 8 Alexander Nyßen CLA 2011-03-25 13:16:07 EDT
Setting background pattern on ScaledGraphics seems to have been resolved by the fixes applied under bug #267728. Resolving this as WORKSFORME.
Comment 9 Xihui Chen CLA 2012-07-09 15:11:42 EDT
This doesn't work actually in zoom states. The coordinates in the Pattern is not zoomed as other methods in ScaledGraphics. This will cause problem in zoom states.
Comment 10 Xihui Chen CLA 2012-07-09 15:50:38 EDT
OK, I have a workaround. You can use the below method to create your pattern:

public static Pattern createScaledPattern(Graphics graphics, Device device,
			float x1, float y1, float x2, float y2, Color color1, int alpha1,
			Color color2, int alpha2) {
		double scale = graphics.getAbsoluteScale();
		return new Pattern(device, (int) (x1 * scale), (int) (y1 * scale),
				(int) (x2 * scale), (int) (y2 * scale), color1, alpha1, color2,
				alpha2);
	}
	
	public static Pattern createScaledPattern(Graphics graphics, Device device,
			float x1, float y1, float x2, float y2, Color color1, Color color2) {
		double scale = graphics.getAbsoluteScale();
		return new Pattern(device, (int) (x1 * scale), (int) (y1 * scale),
				(int) (x2 * scale), (int) (y2 * scale), color1, color2);
	}