Negative dp when using Configurator in AndroidPlot - androidplot

I'm using AndroidPlot and have an issue trying to use a negative value in an XML file.
I'm having this property:
androidPlot.graphWidget.domainLabelHorizontalOffset="-20dp"
And when trying to configure it, it crashes...
Configurator.configure(getActivity().getApplicationContext(), gapFormatter, R.xml.gap_formatter);
The bug seems to come from PixelUtils that uses this pattern:
private static final Pattern DIMENSION_PATTERN = Pattern.compile("^\s*(\d+(\.\d+))\s([a-zA-Z]+)\s*$");
I think that adding a simple "-?" behind the "^" should resolve the problem, but I have many static final method and their classes to override...
private static final Pattern DIMENSION_PATTERN = Pattern.compile("^\-?\s*(\d+(\.\d+))\s([a-zA-Z]+)\s*$");
Does someone have a simple workaround to put some negative dip, please ?
Best regards,

Unfortunately there is no workaround available in 0.6.1. A bug report has been created to track the problem and will be resolved in the next release. I'll update this answer once the fix is available.

Related

Androidplot - getSeriesSet() and other methods in newer AndroidPlot versions

I'm looking at this answer from another question and trying to test it out.
One problem I'm having is a couple of the methods seem to have changed in newer versions of Androidplot. For whatever reason I can't figure out what replacement methods I'm meant to use.
The methods in question are:
mPlot.getSeriesSet().iterator().next() //Cannot resolve getSeriesSet
ValPixConverter.valToPix //Cannot resolve ValPixConverter
widget.getXVal //Cannot resolve .getXVal
My ultimate goal is to be able to place markers on the graph traces
EDIT:
Ok I've figured getXVal/getYVal gets replaced with screenToSeriesX/screenToSeriesY, the rest are still unknown :(
I eventually figured it out :)
mPlot.getSeriesSet().iterator().next() gets replaced with plot2.getRegistry().getSeriesList().iterator().next()
getXVal & getYVal gets replaced with screenToSeriesX & screenToSeriesY
For ValPixConverter I just copied the class from an older version of Androidplot.
This was enough to get me playing around with placing markers/cursor on the graph but a better solution will be formulated for the future.

Processing insists pause() is not a function, when it very much is

Aite, [first poster here, pls don't bash]
So, I'm using the sound library, which I of course remembered to import, and works just fine, proof being given by the fact that all the other functions I used work as expected and give no problems neither in editor nor in execution.
Except, of course, for this little bugger of a pause() function, which I wrote as per below using no different a syntax from all the other functions, only to find out Processing isn't very keen on accepting its existence.
Problem shows both using 3.3.6 and 3.5.
Oh, and also, apparently isPlaying() returns an int, what's up with that?
If, as I'd suspect, that single line below won't be enough code to couple with the info to get to the bottom of it, here's a Dropbox link to the code (since it uses a bunch of files) so you can test it yourself.
It kinda won't work if you try to run it as is tho because it messes up when trying to load all the songs (in the last line of setup), yeah I kinda need some help with that too... works fine if you only load the first one tho!
https://www.dropbox.com/sh/di7mwit0w2l4513/AABipGDAdoKx277f8Hg_ZfhDa?dl=0
(Please, don't expect clear, extensively commented coding. I started working on this way before I learnt that was a thing. Deeply sorry. Of course, you can ask away about anything baffling you)
What did I try, er, writing it well???
I used .play(), .stop(), the volume ones, and they all, as per stated, work fine.
import processing.sound.*;
SoundFile[] songs= new SoundFile[1];
void setup(){
songs[0]=new SoundFile(this,"Small Bump.mp3");
songs[0].play();
}
void draw(){
}
void keyPressed(){
if (songs[0].isPlaying()==1)songs[0].pause();
}
When I copy your code into my Processing editor, I get a couple errors:
songs[0]="Small Bump.mp3";
The sounds array holds instances of SoundFile, but you're trying to store a String value here. Maybe you're looking for the SoundFile constructor?
if (songs[0].isPlaying()==1)
The isPlaying() function returns a boolean value, but you're comparing it to an int value.
songs[i].pause();
You haven't declared this i variable anywhere. Probably meant for this to be a 0.
If I fix all of these errors, then your code compiles fine.
You might want to take a look at the reference for the Sound library here.
The Sound library I had installed was 1.3.2, or something of the likes.
All the references I'd read were for 2.0+.
Having updated that through the "add library" menu, all was solved.

Java Card program using GPJ

So I was tasked to create a java client to communicate with java card.
Right now I can authenticate, write and read data using javax.smartcardio but having a bit of trouble trying to upload cap file and install it.
So after googling around, I found that I can use gpj as a library and use it in my java application to upload and install the cap file.
The problem is I can't find any documentation for gpj and I can't understand the code without one.
Here's one that I have trouble to understand public void installAndMakeSelecatable(AID paramAID1, AID paramAID2, AID paramAID3, byte paramByte, byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
Even when I look on the other part of the code, I can't find out the last parameter since all that use these method will pass null.
So if anyone know where can I find the documentation, I would be really glad. Or better yet, another library that can upload cap file and have some documentation with it.
so far, I've found gpj,jpcsc,jcManager and opal.
Nevermind, it seems that I'm not a clever guy.
For future reference, you can find out what to pass to what method by looking through the main method of the Global Platform Services class. For parameter that you are not sure what to pass, just use null.

LogMF showing error when migrated to Log4j2

My project is currently using log4j1.x version. Now we are converting to log4j2.x
When we removed the log4j1.x jar and put log4j2.x in place, the classes which uses LogMF for logging is showing error.
What is the best alternative for logMF or how to resolve this issue?
Thanks
I tried ParameterizedMessage in log4j2 as an alternative and it is working fine now.
http://logging.apache.org/log4j/2.x/log4j-api/apidocs/org/apache/logging/log4j/message/ParameterizedMessage.html
Example:
log4j2
l4j.debug(new ParameterizedMessage("{} does not match {}", source, p).getFormattedMessage());
LogMF
LogMF.debug(l4j, "{0} does not match {1}", source, p);
There is a log4j-1.x adapter but this does not cover the LogMF class.
May I suggest raising this as a question or feature request on the log4j2 issue tracker or mailing list?
Update:
Are you aware that with Log4J2, the API has improved so your code can now look like this:
logger.debug("Hi {}, my name is {}.", "world", "CoolBird");
There are also alternative ways to use the printf format (but the default way seems to have better performance).

Where did HttpProviders go in IAppHost?

I'm having problems in a project that runs on the v3.9.0.0 version of servicestack.
So I'm trying to download source for it. But on github there are no tags so it seems I cant get hold of the source. So... I downloaded the latest stack and the source for that.
Obviously I'm getting some deprecated warnings but except for that the compiler seems happy enough except for in one place
public virtual void Configure(IAppHost appHost, Container container)
{
appHost.HtmlProviders.Add(new HtmlProvider().ProcessRequest);
The compiler complains that IAppHost does not have a property HtmlProviders
Like so:
ServiceStack.WebHost.Endpoints.IAppHost does not contain a definition for HtmlProviders and no extension method 'HtmlProviders' accepting a first argument of type ServiceStack.WebHost.Endpoints.IAppHost could be found (are you missing a using directive or an assembly reference?)
I can't find anyone mentioning this missing so I'm guessing I'm missing something but what.
So at the end I guess the questions are:
Does anyone know how to get the source for the v3.9.0.0 version of servicestack?
Does anyone know what to do to migrate from v3.9.0.0 to current 3.x version considering the above HtmlProviders problem?
(I edited this post as I misread the version number at first)
Checking history for IAppHost your probably looking for roughly v3.94, about 10 months ago. How to upgrade to latest version? I'd suggest migrating a single service to the new API and going from there.

Resources