ktmprabhu / spray

Automatically exported from code.google.com/p/spray
0 stars 0 forks source link

Styling Text #248

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,

I created a Shape with a text and the text I want to style with transparency 
and setting a font-color. But no changes will do if I try it. What is the issue 
for this siutation. 

If I setup the BackgroundColor of this Text, it works fine. Seems not all 
attributes of styling works.

Here my exmaple code.

shape TabShape {
    stretching(horizontal=false, vertical=false)
    rectangle style TabStyle {
        compartment (
            id = tabCompartment
            layout = fixed
            spacing=2
            margin=2
        )
        position (x=0, y=20)
        size (width=600, height=400)
        style (background-color=RGB (192, 192, 192))
    }
    text{
            align(horizontal=center,vertical=middle)
            position(x=0, y=0)
            size(width=600,height=20)
            style(background-color=blue font-color=red transparency=0.1)
            id=tabID
    }
}

Thanks a lot for regarding.

Greez

dowbar

Original issue reported on code.google.com by dowbar2...@googlemail.com on 4 Apr 2013 at 8:49

GoogleCodeExporter commented 8 years ago
Reproduced, only 

        element_2.setBackground(gaService.manageColor(diagram, new ColorConstant(192, 192, 192)));

is generated inside TabShape.java although font-color has been specified in 
Shape DSL file.

As workaround you can put the other style information pieces inside the 
TabStyle that is referenced at the rectangle. This will be then applied to the 
contained text, too, as the styles are applied to all contained elements, see 
generated TabShape.java:

        ISprayStyle style_2 = new sketch.diagram.styles.TabStyle();
        element_2.setStyle(style_2.getStyle(diagram));
        gaService.setLocationAndSize(element_2, 0, 20, 600, 400);
        SprayLayoutService.setLayoutData(shape_2, 600, 400, true);
        element_2.setBackground(gaService.manageColor(diagram, new ColorConstant(192, 192, 192)));

Original comment by de.abg.r...@gmail.com on 7 Apr 2013 at 2:01

GoogleCodeExporter commented 8 years ago
set priority to low as there is work around with using the referenced style

Original comment by de.abg.r...@gmail.com on 7 Apr 2013 at 2:02

GoogleCodeExporter commented 8 years ago
Hi,

I tried with the StyleFile to style the text, but nothing is changed. Thats why 
I tried to change it directly in the shape-file.  

I have another question, are there anyway to modified the generated 
ShapeFile-Class?
E.g. I want to use Images in this shape, and I modified the genareted ShapeFile 
programmatically. I add this part to the class. 

        Image backgroundImg = gaService.createImage(shape_2, SketchflowImageProvider.TAB_CALENDAR);
        backgroundImg.setFilled(true);
        backgroundImg.setStretchH(true);
        backgroundImg.setStretchV(true);
        gaService.setLocationAndSize(backgroundImg, 0, 0, 600, 420);

But each time I make changes in the Shape-File, the generated-shape-file will 
delete this source code part. Are there anyway to move this class like 
"Features" to the src folder? Or how can I add this ImagePart to SourceCode 
automatically by generating?

Is Spray going to support Images in the Shape-Editor?

best regards,

dowbar

Original comment by dowbar2...@googlemail.com on 8 Apr 2013 at 8:51

GoogleCodeExporter commented 8 years ago
Do you see the style properties used for the text in the generated Java style 
file?

The image support is tracked in issue #121 and to support generation gap 
pattern also for Shape and Style classes is tracked in issue #185.

Original comment by de.abg.r...@gmail.com on 11 Apr 2013 at 7:30

GoogleCodeExporter commented 8 years ago
Yes I see the style setting in the generated shape file.

It was setted in the method:

    /**
     * This method returns the font color for the style. 
     * The font color will be returned separated, because Graphiti allows just the foreground color.
     * The foreground color will be used for lines and fonts at the same time.
     */
    @Override
    public Color getFontColor(Diagram diagram) {
        IGaService gaService = Graphiti.getGaService();
        return gaService.manageColor(diagram, IColorConstant.WHITE);
    }

best regards,

dowbar

Original comment by dowbar2...@googlemail.com on 12 Apr 2013 at 10:25

Attachments:

GoogleCodeExporter commented 8 years ago
Ok, had a look inside the Shape / Style generator: When styling text you have 
to provide all of

* fontName = [name]
* fontSize = [number]
* italic = [yes|no]
* bold = [yes|no]

otherwise nothing is applied.

This should be changed in a way, that when there is no value specified some 
default value is used instead. 

Original comment by de.abg.r...@gmail.com on 12 Apr 2013 at 2:40

GoogleCodeExporter commented 8 years ago
text {
   align (horizontal=center, vertical=middle)
   position (x=0, y=0)
   size (width=600, height=20)
   style (background-color=blue font-name="Arial" font-size=12 font-italic=no font-bold=yes)
   id = tabID
}

-->

{
    Style style = element_2.getStyle();
    String fontName = "Arial";
    int fontSize = 12;
    boolean fontItalic = false;
    boolean fontBold = true;
    style.setFont(gaService.manageFont(diagram, fontName, fontSize, fontItalic, fontBold));
}

Original comment by de.abg.r...@gmail.com on 12 Apr 2013 at 2:48

GoogleCodeExporter commented 8 years ago
Why doesn't it work if I want to make the background of the text and rectangle 
transparent? I only want to show the label without background in other 
rectangles. Is it possible? When I try this, I got this issue 
NullPointerException:

!ENTRY org.eclipse.graphiti.ui 4 0 2013-04-13 00:15:55.646
!MESSAGE GFCommandStack.execute(Command) java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
    at org.eclipse.graphiti.services.impl.GaServiceImpl.manageColor(GaServiceImpl.java:1479)
    at demo.scas.sketchflow.spray.shapes.LabelShape.getShape(LabelShape.java:82)
    at demo.scas.sketchflow.spray.features.SketchflowAddLabelFeatureBase.add(SketchflowAddLabelFeatureBase.java:91)
    at org.eclipse.graphiti.internal.command.AddFeatureCommandWithContext.execute(AddFeatureCommandWithContext.java:76)
    at org.eclipse.graphiti.ui.internal.command.GefCommandWrapper.execute(GefCommandWrapper.java:51)
    at org.eclipse.graphiti.ui.internal.editor.EmfOnGefCommand.execute(EmfOnGefCommand.java:54)
    at org.eclipse.graphiti.internal.command.GFPreparableCommand2.doExecute(GFPreparableCommand2.java:37)
    at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135)

The shape style is defined:
shape LabelShape {
    rectangle style LabelStyle {
        position (x=0, y=0)
        size (width=60, height=25)
        style(background-color=transparent)
        text {
            align (horizontal=center, vertical=middle)
            position (x=0, y=0)
            size (width=60, height=25)
            style (background-color=transparent font-color=black font-name="Arial" font-size=12 font-italic=no font-bold=yes)
            id = labelID
        }
    }
}

But the generated style code contains a line with:
Shape shape_2 = peCreateService.createShape(shape_1, false);
        SprayLayoutService.setId(shape_2, "LabelShape.shape_2");
        Text element_2 = gaService.createPlainText(shape_2);
        ISprayStyle style_2 = style_1;
        element_2.setStyle(style_2.getStyle(diagram));
        gaService.setLocationAndSize(element_2, 0, 0, 60, 25);
        SprayLayoutService.setLayoutData(shape_2, 60, 25, true);
        element_2.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
        element_2.setVerticalAlignment(Orientation.ALIGNMENT_MIDDLE);
        peService.setPropertyValue(element_2, ISprayConstants.TEXT_ID, TextIds.labelID.name());
        peService.setPropertyValue(shape_2, ISprayConstants.TEXT_ID, TextIds.labelID.name());
        element_2.setValue("");
        element_2.setBackground(gaService.manageColor(diagram, null));
        {
            Style style = element_2.getStyle();
            String fontName = "Arial";
            int fontSize = 12;
            boolean fontItalic = false;
            boolean fontBold = true;
            style.setFont(gaService.manageFont(diagram, fontName, fontSize, fontItalic, fontBold));
        }

Is the line with "element_2.setBackground(gaService.manageColor(diagram, 
null))" setting the background transparent?

Thank you very much for responding.

best regards,

dowbar

Original comment by dowbar2...@googlemail.com on 12 Apr 2013 at 10:21

GoogleCodeExporter commented 8 years ago
Hi,

I think you are right, when I style this text with the spray.style file it 
works fine.

Thank you very much for supporting.

best regard,

dowbar

Original comment by dowbar2...@googlemail.com on 13 Apr 2013 at 7:22

GoogleCodeExporter commented 8 years ago
This issue was closed by revision eb0f4f2db0dc.

Original comment by de.abg.r...@gmail.com on 20 May 2013 at 1:04

GoogleCodeExporter commented 8 years ago
This issue was closed by revision eb0f4f2db0dc.

Original comment by karsten....@googlemail.com on 5 Jun 2013 at 8:23