BarRenderer is a raw type. References to generic type BarRenderer<T> should be parameterized? - androidplot

Eclipse shows me the following warning:
"BarRenderer is a raw type. References to generic type BarRenderer should be parameterized"
from the line:
BarRenderer renderer = (BarRenderer)plot.getRenderer(BarRenderer.class);
How can I fix this warning?

It's unclear exactly what you're trying to do here (have you created a custom renderer etc.) but to get past your immediate error you can try changing the line above to this:
BarRenderer<BarFormatter> renderer = (BarRenderer<BarFormatter>)plot.getRenderer(BarRenderer.class);

Related

Unable to cast object of type 'PX.Objects.IN.INLotSerialStatus' to type 'PX.Objects.IN.Overrides.INDocumentRelease.LotSerialStatus'. in acumatica

While multiple lot Allocation I am getting error:
Unable to cast object of type 'PX.Objects.IN.INLotSerialStatus'
to type 'PX.Objects.IN.Overrides.INDocumentRelease.LotSerialStatus'.
First unpublish all customization and try to reproduce the issue.
If it goes away re-publish customizations one by one until you find the one causing the cast error.
Review the code of the customization for all references to INLotSerialStatus and LotSerialStatus. Also look at Acumatica traces to find more details about the error.
A LotSerialStatus object is also a INLotSerialStatus because LotSerialStatus inherits from INLotSerialStatus. This is a valid assignment.
The inverse is not true, maybe there is an invalid assignment for which no cast is possible in the source code of the customization:

Initializing custom view in Android Studio: Expected resource of type xml

I have a custom view called IconView, which has the following constructor for initialization:
public class IconView extends RelativeLayout implements Checkable {
...
public IconView(Context context, AttributeSet attrs, boolean useDefaultImage) {
super(context, attrs);
inflateLayout(context);
...
In order to initialize AttributeSet instance from XMLfor constructing the view, I use getResources().getXml(R.layout.icon_view), false);.
This compiles successfully and runs correctly. However, Android studio highlights the code and displays me this error:
The detailed description of the error is here:
Expected resource of type xml less... (Ctrl+F1)
Reports two types of problems:
Supplying the wrong type of resource identifier. For example, when
calling Resources.getString(int id), you should be passing
R.string.something, not R.drawable.something.
Passing the wrong
constant to a method which expects one of a specific set of
constants. For example, when calling View#setLayoutDirection, the
parameter must be android.view.View.LAYOUT_DIRECTION_LTR or
android.view.View.LAYOUT_DIRECTION_RTL.
The question:
Although the code works, I do not know, how to rewrite it, so that the error would disappear in Android Studio. The error is visually annoying, so how could I get rid of it?
Resources#getXml(int id) is used to get the resource of type xml, which lays inside the xml resource folder. You, on the other hand, passing R.layout.icon_view here, the layout resource.
Use getResources().getLayout(R.layout.icon_view) here and the error will disappear.
P.S.: the documentation on Resources#getLayout() says the following:
This function is really a simple wrapper for calling getXml(int) with a layout resource.
So it looks like this is some kind of lint-related issue. Either way, getLayout() does not result in this error.

Map types nesting issue

I'm trying to create this sort of Map:
var map:Map = new Map<Dynamic, Array<ProductData>>();
But compiler throws an error : Unexpected ;
So it doesn't like the types declaration nesting. But I really do need that Array<ProductData> as a value of a map.
How can I overcome this mistake?
That's interesting, since I get a different error with that code:
Invalid number of type parameters for Map
That is fixed by removing the :Map though (just let type inference handle that).
After that, though, I get the following error:
Abstract Map has no #:to function that accepts IMap>
...or in other words - you can't have a Map with Dynamic keys in Haxe. Why are you using Dynamic there in the first place? Could that maybe be statically typed?

Is it OK to define an opaque type as an empty struct to get around linker warning in C++/CLI?

I have a C++ project that is configured to use CLR. The project contains a subclass of CTreeCtrl, i.e. a class provided by Microsoft that I have no control over. Since the public interface of CTreeCtrl heavily uses the type HTREEITEM, it is unavoidable that the subclass also makes use of the type - but since the type is "opaque", the subclass only passes around HTREEITEM references without actually doing anything with the referenced objects.
By "opaque", I mean that HTREEITEM is only visible as a forward-declared type. Here's the declaration that I see in CommCtrl.h:
struct _TREEITEM;
typedef struct _TREEITEM *HTREEITEM;
Unfortunately, in a release build this usage of HTREEITEM generates the following linker warning:
foo.obj : warning LNK4248: unresolved typeref token (01000017) for '_TREEITEM'; image may not run
Here is the MSDN link for the warning. I have searched the net for a solution to get rid of the warning, but have found nothing - only confirmation that over the years other people have encountered this warning in relation to HTREEITEM as well.
Now I have been thinking of a workaround myself. Given that
My class only gets HTREEITEM references from CtreeCtrl and passes them back to CtreeCtrl, without any kind of interpretation or function calls
HTREEITEM is merely a pointer to _TREEITEM
It follows that all that my class ever does is pass around pointers to _TREEITEM. My idea for a workaround therefore is this: Why not define _TREEITEM as an empty struct in my project, like this:
struct _TREEITEM
{
};
Obviously this makes the linker happy since it now sees the complete type. The fact that the struct definition is incorrect is not relevant since my class is only passing around pointers to _TREEITEM, i.e. all that the compiler needs to know is the size of a HTREEITEM.
I have tried this workaround and it seems to work, not only at compile time but at runtime as well. So what do you think of this workaround? Did I overlook something? I certainly won't be offended if you call it an ugly hack :-)
FWIW: I am currently on Visual Studio 2010.

C# objects Xaml factory method for XamlWriter

My class uses an image as Property (public Image myImage). When this class is serialized (XamlWriter) it works fine, reading it back gives an exception:
'No matching constructor found on type
'System.Drawing.Bitmap'. You can use
the Arguments or FactoryMethod
directives to construct this type.'
Line number '5' and line position '8'.
Obviously there is a constructor missing for Bitmap with ColorPalette as argument:
<sd:Bitmap>
<sd:Bitmap.Palette>
<sdi:ColorPalette />
</sd:Bitmap.Palette>
</sd:Bitmap>
I understand that I can specify a factory method creating the bitmap somehow. I also found some articles about directives for this such as http://www.wpftutorial.net/XAML2009.html
However, I am not an expert in Xaml and do not understand how and where to define / declare the method on my attribute. Unfortunately i do also not find an example for this.
I expect some like
[FactoryMethod("XYZ")]
public Image myImage ....
but actually have found nothing. Any idea / example you know?

Resources