how to display a pie chart in blackberry application [closed] - blackberry

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
How to display a pie chart in blackberry application using rim apis?
Are there controls available in the rim apis or how can it be done? Can some help me by sharing the code snippet

The Google Chart API allows you to provide a URL to the Google service, which in turn returns a chart image. This capability is useful from the BlackBerry smartphone because data can be passed from the BlackBerry smartphone and generates a corresponding chart image on the BlackBerry smartphone.
here are the type of the chat you can do
Here are the chat types defined in Google API.
public static final String LINE_C = "lc";
public static final String LINE_S = "ls";
public static final String LINE_XY = "lxy";
public static final String BAR_HORIZONTAL_STACKED = "bhs";
public static final String BAR_VERTICAL_STACKED = "bvs";
public static final String BAR_HORIZONTAL_GROUPED = "bhg";
public static final String BAR_VERTICAL_GROUPED = "bvg";
public static final String BAR_ = "b";
public static final String PIE = "p";
public static final String PIE_3D = "p3";
public static final String PIE_CONCENTRIC = "pc";
public static final String VENN = "v";
public static final String SCATTER = "s";
public static final String RADAR = "r";
public static final String RADAR_SPLINES = "rs";
public static final String MAP = "t";
public static final String GOOGLE_O_METER = "gom";
public static final String QR_CODE = "qr";
The all you need to do is to request the chat URL. it will download as image to your device. The URL format is given below.
http://chart.apis.google.com/chart?&cht=p3&chd=t:250,100,40&chs=320x200&chl=Apple|Grapes|Mango
cht = chart type
chd = chart data
chs = chart size
chl = chart label
Enjoy.

Related

Vaadin 14 GridPro element does not reflect change in UI

I'm using a GridPro component for a CustomField. The grid is backed by a ListDataProvider. The grid is initialized like so:
this.grid.addEditColumn(new ValueProvider<Item, String>() {
private static final long serialVersionUID = 1L;
#Override
public String apply(final Item source) {
return (String)source.get(prop.getName());
}
}, new TextRenderer<Item>(new ItemLabelGenerator<Item>() {
private static final long serialVersionUID = 1L;
#Override
public String apply(final Item item) {
String val = (String)item.get(prop.getName());
return StringTools.isValidString(val) ? val : "";
}
})).text(new ItemUpdater<Item, String>() {
private static final long serialVersionUID = 1L;
#Override
public void accept(final Item item, final String newValue) {
Item dataProviderItem = (Item)dataProvider.getId(item);
dataProviderItem.set(prop.getName(), newValue);
TableField.this.dataProvider.refreshItem(dataProviderItem);
}
}).setHeader(prop.getName());
The problem I'm having is that when I'm editing a cell its content is not updated in the UI and it still shows the old value. The renderer properly returns the new value, and the ValueProvider as well sets the new text value correctly.
The problem was the the POJO I was using as a type parameter to GridPro did not have an invariable ID thus the dataProvider.refreshItem was not able to find it in the backing set and update it. See https://vaadin.com/forum/thread/18453090/grid-with-editor-can-t-save-changed-data for details.
You are at least setting it up in overly complicated manner. Java 8 allows you to setup text field in GridPro with just few lines of code like this. Say you have Grid<Person> and Person#getFirstName returns the first name and Person#setFirstName respectively is the setter for the property, you need only this. Calling DataProvider#refreshItem is not needed, as GridPro will do this internally as well.
grid.addEditColumn(Person::getFirstName)
.text((item, newValue) -> item.setFirstName(newValue))
.setHeader("First name");
See more examples in documentation.

accessing static final property in grails service

I get a no such property error when trying to access the final properties of one class from inside a service class.
In a service I have the following code.
class ShiftService{
...
def getEvents(shift){
//if I try to access static final get error
def type=shiftEvent.START;
//NO SUCH PROPERTY shiftEvent for ShiftService
}
...
}
//currently in same ShiftService.groovy file
class shiftEvent{
static final String START="shiftStart";
static final String END="shiftEnd";
static final String DAY_BOUNDARY="dayBoundary";
static final String CHECKIN="individualCheckin";
static final String CHECKOUT="individualCheckout";
static final String NIGHT_START="individualNightStart";
static final String NIGHT_END="individualNightEnd";
...
}

Where do I specify the user I want to follow in twitter hbc

Hey I would like to have the latest tweets from certain users that I will follow to be displayed on a page of my web app. So I followed the tutorial on the git of horsebird client but I don't know where I have to specify the users I want the messages from.
public class TwitterLatestTweets implements Runnable {
private final static String BUNDLE_BASENAME = "configuration.twitter";
private final static String CONSUMER_KEY = ResourceBundle.getBundle(
BUNDLE_BASENAME).getString("consumerKey");
private final static String CONSUMER_SECRET = ResourceBundle.getBundle(
BUNDLE_BASENAME).getString("consumerSecret");
private final static String TOKEN = ResourceBundle.getBundle(
BUNDLE_BASENAME).getString("token");
private final static String SECRET = ResourceBundle.getBundle(
BUNDLE_BASENAME).getString("secret");
private List<String> msgList = new ArrayList<String>();
#Override
public void run() {
/**
* Set up your blocking queues: Be sure to size these properly based on
* expected TPS of your stream
*/
BlockingQueue<String> msgQueue = new LinkedBlockingQueue<String>(100000);
BlockingQueue<Event> eventQueue = new LinkedBlockingQueue<Event>(1000);
/**
* Declare the host you want to connect to, the endpoint, and
* authentication (basic auth or oauth)
*/
Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST);
StatusesFilterEndpoint hosebirdEndpoint = new StatusesFilterEndpoint();
Authentication hosebirdAuth = new OAuth1(CONSUMER_KEY, CONSUMER_SECRET,
TOKEN, SECRET);
ClientBuilder builder = new ClientBuilder().hosts(hosebirdHosts)
.authentication(hosebirdAuth).endpoint(hosebirdEndpoint)
.processor(new StringDelimitedProcessor(msgQueue))
.eventMessageQueue(eventQueue);
Client hosebirdClient = builder.build();
hosebirdClient.connect();
while (!hosebirdClient.isDone()) {
try {
String msg = msgQueue.take();
msgList.add(msg);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
hosebirdClient.stop();
for (String s : msgList) {
System.out.println(s);
}
}
}
}
Is it Constants.STREAM_HOST ? Could you give me an example with the white house twitter (https://twitter.com/whitehouse) ?
You need to add a list of userIds to your endpoint, like this:
hosebirdEndpoint.followings(userIds);
You've got several examples here, in the same github project you've provided in your question. This one uses the same endpoint as in your post.
In here you can find Twitter's documentation on the endpoint, and the full list of the parameters you can use.

RabbitMQ: Publishing from an ASP.NET MVC application

My understanding is that IModel instances are reasonably cheap to create and that's what I started with. I was creating a separate IModel for each class that was ever using it: each Application Service class gets its own IModel, as does every Controller. It was working fine, but having 30+ channels open was a bit worrisome.
I thought about serializing access to a shared IModel:
lock(publisherLock)
publisherModel.BasicPublish(...);
but now there's a point of contention for no good reason.
So, what will be the correct way of publishing messages into a RabbitMQ exchange from an ASP.NET MVC application?
What you must not do is allow a channel to be used by more than one thread, so keeping channels open over several requests is a bad idea.
IModel instances are cheap to create, but not free, so there are a couple of approaches you can take:
The safest thing to do is simply to create a channel each time you want to publish and close it again straight away. Something like this:
using(var model = connection.CreateModel())
{
var properties = model.CreateBasicProperties();
model.BasicPublish(exchange, routingKey, properties, msg);
}
You can keep the connection open for the lifetime of the application, but be sure to detect if you loose the connection and have code to reconnect.
The downside with this approach is that you have the overhead of creating a channel for each publish.
The alternative is to hold a channel open on a dedicated publishing thread and marshal all your publish calls onto that thread using a BlockingCollection or similar. This will be more efficient, but more complex to implement.
Here is something which you can use,
BrokerHelper.Publish("Aplan chaplam, chaliye aai mein :P");
and below is the defination for the BrokerHelper class.
public static class BrokerHelper
{
public static string Username = "guest";
public static string Password = "guest";
public static string VirtualHost = "/";
// "localhost" if rabbitMq is installed on the same server,
// else enter the ip address of the server where it is installed.
public static string HostName = "localhost";
public static string ExchangeName = "test-exchange";
public static string ExchangeTypeVal = ExchangeType.Direct;
public static string QueueName = "SomeQueue";
public static bool QueueExclusive = false;
public static bool QueueDurable = false;
public static bool QueueDelete = false;
public static string RoutingKey = "yasser";
public static IConnection Connection;
public static IModel Channel;
public static void Connect()
{
var factory = new ConnectionFactory();
factory.UserName = Username;
factory.Password = Password;
factory.VirtualHost = VirtualHost;
factory.Protocol = Protocols.FromEnvironment();
factory.HostName = HostName;
factory.Port = AmqpTcpEndpoint.UseDefaultPort;
Connection = factory.CreateConnection();
Channel = Connection.CreateModel();
}
public static void Disconnect()
{
Connection.Close(200, "Goodbye");
}
public static bool IsBrokerDisconnected()
{
if(Connection == null) return true;
if(Connection.IsOpen) return false;
return true;
}
public static void Publish(string message)
{
if (IsBrokerDisconnected()) Connect();
Channel.ExchangeDeclare(ExchangeName, ExchangeTypeVal.ToString());
Channel.QueueDeclare(QueueName, QueueDurable, QueueExclusive, QueueDelete, null);
Channel.QueueBind(QueueName, ExchangeName, RoutingKey);
var encodedMessage = Encoding.ASCII.GetBytes(message);
Channel.BasicPublish(ExchangeName, RoutingKey, null, encodedMessage);
Disconnect();
}
}
Further reading : Introduction to RabbitMQ with C# .NET, ASP.NET and ASP.NET MVC with examples

How to start another apps when click a button?

I want to start another apps when I click this button.
sharebtn = new Custom_ButtonField(share, shareactive, shareactive) {
protected boolean navigationClick(int status, int time) {
//I want to start another apps (Strawberry)
return true;
}
};
add(sharebtn);
Here is the Strawberry Apps
public class StrawBerry extends UiApplication implements ActionListener {
public static void main(String url) {
new StrawBerry(url).enterEventDispatcher();
}
}
I want to pass String url to Strawberry apps. How can I achieve this?
First your main method won't be never called by system. The right signature:
public static void main(String[] arguments){}
Take a look on this article to launch another app with parameters : How To - Launch a third-party application from another third-party application
To post on FB page. You need something like:
private final String NEXT_URL = "http://www.facebook.com/connect/login_success.html";
private final String APPLICATION_ID = "your id";
private final String APPLICATION_SECRET = "your secret";
private Facebook fb;
private User user;
...
fb = Facebook.getInstance(new ApplicationSettings(NEXT_URL, APPLICATION_ID, APPLICATION_SECRET, Facebook.Permissions.PUBLISH_STREAM));
user = fb.getUser(pUserId);
user.publishPost(messageEditField.getText(), linkEditField.getText(), pictureEditField.getText(), nameEditField.getText(), captionEditField.getText(), descriptionEditField.getText(), sourceEditField.getText());

Resources