[BIRT 2.3.2 (StandAlone)]"Jumping" problem? - java

Here's the fact : I made a tiny app which consist of a table related to a bar chart (a birt one ... of course), when I modify my table values it automaticaly alter my chart (like Excel but less fancy) ...
Anyway everything works fine ... BUT when I want to make my chart interactive in order to show tooltips (for example) I inform naturaly my
IDeviceRenderer
whit the following command
idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, this );
but doing so brings an error when (much later) my code come to
gr.render(idr, gr.build(idr.getDisplayServer(), this.chart, bo, vroum,null));
(Which have never failed before) ...
I feel lost ...
ps:
The error I get are that I get no bars to my chart and receive the following error message :
org.eclipse.birt.chart.exception.ChartException
at org.eclipse.birt.chart.factory.Generator.render(Generator.java:1373)
at clickable.chart.ClickableProto.paintControl(ClickableProto.java:520)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:217)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1424)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3842)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4541)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2371)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3420)
at clickable.chart.ClickableProto.main(ClickableProto.java:151)
Caused by: java.lang.NullPointerException
at org.eclipse.birt.chart.render.InteractiveRenderer.isColoredByCategories(InteractiveRenderer.java:197)
at org.eclipse.birt.chart.render.InteractiveRenderer.getSource(InteractiveRenderer.java:161)
at org.eclipse.birt.chart.render.InteractiveRenderer.modifyEvent(InteractiveRenderer.java:116)
at org.eclipse.birt.chart.device.swt.SwtRendererImpl.fillPolygon(SwtRendererImpl.java:502)
at org.eclipse.birt.chart.event.PolygonRenderEvent.fill(PolygonRenderEvent.java:156)
at org.eclipse.birt.chart.render.DeferredCache.flushPlanes(DeferredCache.java:499)
at org.eclipse.birt.chart.render.DeferredCache.flushOptions(DeferredCache.java:271)
at org.eclipse.birt.chart.render.DeferredCacheManager.flushOptions(DeferredCacheManager.java:165)
at org.eclipse.birt.chart.render.AxesRenderer.flushClipping(AxesRenderer.java:3416)
at org.eclipse.birt.chart.render.AxesRenderer.restoreClipping(AxesRenderer.java:3401)
at org.eclipse.birt.chart.render.Bar.renderSeries(Bar.java:1533)
at org.eclipse.birt.chart.render.AxesRenderer.renderPlot(AxesRenderer.java:2181)
at org.eclipse.birt.chart.render.AxesRenderer.render(AxesRenderer.java:314)
at org.eclipse.birt.chart.factory.Generator.render(Generator.java:1368)
... 14 more
I am open to any idea !

Finally I managed it on my own ...
So here are some common mistakes not to make when you make a chart on BIRT and wnat it to be interactive ...
1 Implement barely anything which need to be overriden
        I personnaly forgot to override
getDesignTimeModel()
and
getRunTimeModel()
comming with the ICallBackNotifier implementation ...
2 Do not nest your chart (or be prepared to nest most of your methods too)
        I had my chart not directly on my shell but nested in a bunch of composites widgets, canvas and such ... Therefore my canvas where hidding my shell which was the only one able to react in the way I wanted to my mouse controller.
(Funny fact : I figured this all out when I (for no reason) tried to drag a small part of my shell which was not overlapped by the chart and drop it on my bars ... There the tooltip poped ... ^^ Funny way to understand how things work :p)
3 Do not be me ...
        It is to much work and pain for a barely acceptable result ;p
Hope this help, dont hesitate to mail me if you face the same probleme, I'd be glad to help as much as I can ^^

Related

PDFBox - How to push/unpush a PD(Push)Button

For building a workaround, I'd like to know if it's possible to push/unpush a PD(Push)Button with pdfbox 2.0.12 or later.
PDButton pdButton = (PDButton) field;
pdButton.setValue("pushed");
Is there a certain value that can be used to push/unpush the button?
I'm aware that this should rather be solved with a PDCheckBox, but as most of our PDF-templates use buttons rather than checkboxes to display checkboxes I'd like to ease the migration of those files.
Update 1
As suggested in the comments I tried setting the button to one, but that leads to an IllegalStateException.
Code
PDButton btn = (PDButton) field;
btn.setValue("1");
Exception
Caused by: java.lang.IllegalStateException
at org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceEntry.getSubDictionary(PDAppearanceEntry.java:97)
at org.apache.pdfbox.pdmodel.interactive.form.PDButton.getOnValueForWidget(PDButton.java:348)
at org.apache.pdfbox.pdmodel.interactive.form.PDButton.getOnValues(PDButton.java:319)
at org.apache.pdfbox.pdmodel.interactive.form.PDButton.checkValue(PDButton.java:370)
at org.apache.pdfbox.pdmodel.interactive.form.PDButton.setValue(PDButton.java:157)
Update 2
Not possible. Only checkboxes can be checked/unchecked. We'll fix our PDF templates.

android studio graphic editor no showing the layout picture

For some reason on the project I am working on in Android Studio the XML graphic editor has stopped showing me the picture of the screen layout. The app itself works fine and the layout woks fine on my device, but I don't have a picture of it on my computer screen in the editor.
The editor shows a error Rendering Problem - Exception raised during rendering
in the details it shows me a stack trace of a java.lang.NullPointerException, and it tip is to try and refresh the layout, but that doesn't work. I tried to refresh, to rebuild, and every other kind of refresh possible but nothing works. I checked other projects that I had worked on and thy where OK the graphics was fine, but not on my current project. So I need help finding the problem.
java.lang.NullPointerException
at android.graphics.BidiRenderer.getScriptFont(BidiRenderer.java:290)
at android.graphics.BidiRenderer.getScriptRuns(BidiRenderer.java:280)
at android.graphics.BidiRenderer.renderText(BidiRenderer.java:133)
at android.graphics.BidiRenderer.renderText(BidiRenderer.java:108)
at android.graphics.Paint_Delegate.measureText(Paint_Delegate.java:1310)
at android.graphics.Paint_Delegate.nGetTextAdvances(Paint_Delegate.java:972)
at android.graphics.Paint_Delegate.nGetRunAdvance(Paint_Delegate.java:1147)
at android.graphics.Paint.nGetRunAdvance(Paint.java)
at android.graphics.Paint.getRunAdvance(Paint.java:2729)
at android.text.TextLine.getRunAdvance(TextLine.java:729)
at android.text.TextLine.handleText(TextLine.java:778)
at android.text.TextLine.handleRun(TextLine.java:1018)
at android.text.TextLine.measureRun(TextLine.java:417)
at android.text.TextLine.measure(TextLine.java:310)
at android.text.TextLine.metrics(TextLine.java:281)
at android.text.Layout.measurePara(Layout.java:1966)
at android.text.Layout.getDesiredWidthWithLimit(Layout.java:186)
at android.widget.TextView.onMeasure(TextView.java:8168)
at android.view.View.measure(View.java:22035)
at android.widget.Toolbar.measureChildCollapseMargins(Toolbar.java:1548)
at android.widget.Toolbar.onMeasure(Toolbar.java:1662)
at android.view.View.measure(View.java:22035)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6622)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.widget.ActionBarContainer.onMeasure(ActionBarContainer.java:291)
at android.view.View.measure(View.java:22035)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6622)
at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:378)
at android.view.View.measure(View.java:22035)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure(View.java:22035)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:590)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:343)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:384)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:547)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:681)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
In xml toolbar you can find refresh button, so that it will notify if it is any warnings in your xml.
If your used custom layout then rendering problem shown..
Let see the error log:
java.lang.NullPointerException
at android.graphics.BidiRenderer.getScriptFont(BidiRenderer.java:290)
I think you need to clone project like library module, then add #Nullable to this method to avoid exception here.
if view is rendering fine at run time but you are only having problem showing preview in layout editor then you should use isInEditMode() method and should not do unsupported operations if view is being rendered in layout editor
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (!isInEditMode()) {
//custom logic
}
}
I am sorry to say that your answers did not help me at all. The solution for me was to go back to one of my backup visions, when the edit display still worked, and start from there. I found that when changing too many parameters in the Theme Editor (three) cause a bug that stops the XML editor from showing the layout picture.
One of the things I learned many years ago when first started to learn programming was that there is no such thing as to many backups, this is one of those time when I am glad I listed to my teachers.

Displaying animated SVG in JavaFX on different computers fails

I'm currently working on a JavaFX program with some fellow students.
We organized everything with GIT - thus, our SVG-files look alike.
We are also doing some animation within our SVG.
The problem is, that when my friends start their NetBeans, the SVG is not displayed correctly. Some parts are missing out. When they open the SVG with their web-browser however - it works.
Here's the part that is missing out on my friends PC.
<polyline id="beampath" stroke="brown" stroke-width="4" fill="transparent">
<animate id="bridgeLeft" attributeName="points" dur="1s"
begin = "0s; bridgeLeft.end + 2.5s "
from="20,62 30,62 35,62 50,62 "
to="20,62 30,62 35,70 45,88"
fill = "freeze"
/>
</polyline>
Does someone have any clue why that's the case?
We're really desperate.

Tapestry5 Ajaxformloop limit number of rows

I am trying to limit the number of rows that a user can add in an ajaxformloop.
Short example:
For example, the loop found in the tapestry 5 documentation here: http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/corelib/components/AjaxFormLoop.html
If for example I would only like the user to be able to enter 3 phone numbers, how can that be done?
What I have tried:
1) I tried returning null from the onAddRow event, this causes an exception and the exception report page to display - these events shouldn't return null I don't think.
2) I tried adding my own add row button like this:
<p:addRow>
<t:addrowlink>Add another</t:addrowlink>
</p:addRow>
And then putting a t:if around it, like this:
<t:if test="canAddMorePhones()">
<p:addRow>
<t:addrowlink>Add another</t:addrowlink>
</p:addRow>
</t:if>
In this case, the "add another" reverts to the default "Add row" button and my add row link doesn't show.
3)I tried moving that t:if inside the , this had similar results.
--------------------------
I am sure that this is a fairly common aim, is there any simple way to do it? Perhaps someone can provide an example, and if possible this can help to go in the documentation as i'm sure i'm not going to be the only one trying to do this.
Note: I did also ask on the T5 users mailing list and had one answer but I can't seem to get it working after the response from Lance (Which I am sure is probably correct, but i'm not sure how to use the AjaxResponseRenderer as per my reply last week, this is probably due to my own technical limitations or understanding of some parts of T5).
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Ajaxformloop-add-row-link-max-size-tt5730840.html
I also tried using ajaxResponseRenderer.addRender as you did in your mailing list code, but it doesn't work because it seems that Tapestry has some problems dealing with updating a component that's busy updating another component. However, AjaxResponseRenderer also supports execution of JavaScript. Taking this approach on the AjaxFormLoop example in the docs, specify the addrowlink as follows:
<p:addrow>
<t:if test="canAddMorePhones()">
<t:addrowlink id="addRowLink" t:id="addRowLink">Add another</t:addrowlink>
</t:if>
</p:addrow>
Then add the following code right before return phone; in onAddRowFromPhones():
ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
public void run(JavaScriptSupport javascriptSupport) {
if (!canAddMorePhones()) {
javascriptSupport.addScript("document.getElementById('addRowLink').style.display = 'none';");
}
}
});
This example was tested successfully in Tapestry 5.3.7.

Java Swing with own L&F sometimes suddenly switches back to default L&F

In a Java Swing application that uses several own UI's (e.g. for JTabbedPane) sometimes right after startup, the Look and Feel (L&F) of the entire application changes back to the default. It quickly shows everything correct and then after a second or less the entire application changes to the ugly default.
Unfortunately, this is difficult to reproduce. It happens very rarely and so far only under Ubuntu when I start it directly from within Eclipse using java-1.6.0-openjdk-amd64. I have a newer java version installed too, but I use 1.6 to test compatibility.
Since it happens either for all or for no component, it looks like it does not matter how I I derive the UI. It even changes back this little change where no custom UI is used:
JTextField textField = new JTextField();
textField.setBorder(null);
So if it happens, then the border will show up.
Since this is difficult to reproduce, I can not give a code example where it always happens. Actually, the one above is already an example, but it does not happen always. But I hope to find someone who run into a similar issue where the L&F or any changes to it suddenly and unwanted changed back to the default. If so, I would appreciate if you could share your experience and hopefully a solution.
---------------- Edit:
I found two workaraounds:
For the border problem, I simply use textField.setBorder(new EmptyBorder()); instead of setting it to null.
For the reset of the UI, which was indeed caused by unwanted calls to updateUI, I created for my customized swing objects subclasses that override updateUI(), e.g.:
public class JTabbedPaneNoHeads extends JTabbedPane {
public JTabbedPaneNoHeads() {
setUI(new GUITabbedPaneNoHeadsUI());
}
#Override
public GUITabbedPaneNoHeadsUI getUI() {
return (GUITabbedPaneNoHeadsUI) ui;
}
#Override
public void updateUI() {
/* This was to find out who is calling updateUI:
StackTraceElement[] _stackTrace = Thread.currentThread().getStackTrace();
for (StackTraceElement element : _stackTrace ){
System.out.print(element + " -- ");
}
System.out.println();
*/
setUI(new GUITabbedPaneNoHeadsUI());
}
}
Now everything works fine.
btw: the calls to updateUI had the following stack trace (generated by the commented block in the code above):
livedocket.GUI.design.JTabbedPaneNoHeads.updateUI(JTabbedPaneNoHeads.java:22)
javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1230)
.... many more of these updateComponentTreeUI0 ...
javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1245)
javax.swing.SwingUtilities.updateComponentTreeUI(SwingUtilities.java:1221)
javax.swing.plaf.metal.MetalLookAndFeel$AATextListener.updateWindowUI(MetalLookAndFeel.java:2329)
javax.swing.plaf.metal.MetalLookAndFeel$AATextListener.updateAllUIs(MetalLookAndFeel.java:2342)
javax.swing.plaf.metal.MetalLookAndFeel$AATextListener.access$200(MetalLookAndFeel.java:2295)
javax.swing.plaf.metal.MetalLookAndFeel$AATextListener$1.run(MetalLookAndFeel.java:2370)
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:226)
java.awt.EventQueue.dispatchEventImpl(EventQueue.java:673)
java.awt.EventQueue.access$300(EventQueue.java:96)
java.awt.EventQueue$2.run(EventQueue.java:634)
java.awt.EventQueue$2.run(EventQueue.java:632)
java.security.AccessController.doPrivileged(Native Method)
java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:108)
java.awt.EventQueue.dispatchEvent(EventQueue.java:643)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
As I mentioned before, these calls happen only very rarely and only on Java 1.6.
I have seen similar symptoms in an application with threading problems - if I were you I would double-check if all of the GUI is constructed on the Event Dispatch Thread.

Categories