cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re-coloring a diagram item via Java API

BHopp
Senior Member

Hello,

 

I'm trying to change the color of diagram shapes in an existing diagram using the Java API. While the erase and width/height-methods of DrawingItem work, resetting the brush, pen and/or font do not. The MEGA version is 2009 SP 5 patch 6 release 6.

 

The code I'm using is as follows:

 

...

megaEn.setCurrentAdministrator("Importer");

...

MegaObject diagram = root.getObjectFromID("3Cw5P8J9Ez1R");

MegaDrawing drawing = MegaServiceBuilder.getDrawingOf(diagram);

 

DrawingObjectCollection drawingObjects = drawing.drawingObjects();

while(drawingObjects.hasNext()) {

 

         DrawingObject drawingObject = drawingObjects.next();

 

         short alpha = 255;

        shortblue = 30;

        shortgreen = 100;

         short red = 30;

 

      

         DrawingItem item = drawingObject.drawingItem();

         DrawingBrush brush = item.brush();

 

         brush.linearGradientColor1Set(alpha, blue, green, red);

         brush.linearGradientColor2Set(alpha, blue, green, red);

 

         item.brush(brush);

}

 

...

 

I've tried re-setting the type of the brush and setting the corresponding colors, too, as well as changing the DrawingPen and DrawingFont, both without success. I've tried setting the color matrix, and I've tried to apply all of these steps to the sub-DrawingItems. I've also tried different alpha and color values for each of these steps.

 

Thanks in advance and regards,

 

B. Hopp

0 Replies