Graphic pieChart with MPAndroidChart with image - java

I would like to make the next graphic with MPAndroidChart, but the pie chart is not possible to add an image, then someone knows how to add it's
enter image description here

MPAndroidChart you can add drawable icon as a label. Here is sample how to add drawable.
List<PieEntry> entries = new ArrayList<>();
Drawable icon = ContextCompat.getDrawable(getActivity(), R.drawable.name);
// Set the drawable icon to piechart
entries.add(new PieEntry(18.5f, icon));
PieDataSet set = new PieDataSet(entries, "Election Results");
PieData data = new PieData(set);
pieChart.setData(data);

Related

Align Text and Image vertically with iText 2

I'm trying to print an Image and a text next to each other into a PdfPCell. The image is bigger than the font size, so the row height is increased. iText renders the Text at the bottom of the baseline (First example).
But I want the text to be vertically aligned in the middle of the cell (Second example).
What can I do to change this? I know I can change the alignment of the cell, but that doesn't change anything.
PdfPCell getImageAndText(byte[] image, String text, int originalDimension){
final Image pdfImg = Image.getInstance(image);
//Scale to 16pt.
pdfImg.scalePercent(16 * 100f / originalDimension);
Phrase image = new Phrase(new Chunk(pdfImg, 0, 0));
//Create Cell with image
final PdfPCell cell = new PdfPCell(image);
//Add text to cell
cell.addElement(new Phrase(text, getFont()));
return cell;
}
I am using iText 2.1.7

JavaFX table contours of the table

Hi could you help me how I can do contours of the table. I want that all rows in table have contours .Thanks for help. My table look like this :
TableColumn busNumberCol = new TableColumn("Linia");
busNumberCol.setCellValueFactory(
new PropertyValueFactory<>("busNumber"));
busNumberCol.setPrefWidth(tb.getPrefWidth()/5);
TableColumn courseCol = new TableColumn("Kierunek");
courseCol.setCellValueFactory(
new PropertyValueFactory<>("nameBusStpo"));
courseCol.setPrefWidth((tb.getPrefWidth()-tb.getPrefWidth()/5)/2-1);
TableColumn departureCol = new TableColumn("Odjazd");
departureCol.setPrefWidth((tb.getPrefWidth()-tb.getPrefWidth()/5)/2-1);
departureCol.setCellValueFactory(
new PropertyValueFactory<>("busTimetable"));
table.setPrefHeight(tb.getPrefHeight());
table.setStyle("-fx-background-color: orange");
table.setPrefWidth(tb.getPrefWidth());
table.setItems(list);
table.getColumns().addAll(busNumberCol, courseCol, departureCol);
table.setPlaceholder(new Label(""));
You can use:
.table-row-cell{
-fx-border-color:red;
-fx-border-width:1.0;
/* -fx-background-color */
}
Mention that it this adds a border around every row.For background color you can uncomment the above with /* -fx-background-color*/
Also
For more styling on TableView look Change JavaFX TableView font size
try this in the css(for me is working):
.table-row-cell{
-fx-background-color: -fx-table-cell-border-color, /*coloryouwant*/;
}

Libgdx - Creating larger background for scrollpane

I'm trying to create a scrollpane that has a background. However, I want the background to take up more than the area of the scrollpane. For instance, Here is my background and colored in red is where I want the scrollpane to be:
However, when I add buttons I get the following result:
How can I limit the actual scrollpane part to just a section (colored in red in the above picture)?
Here is what I have so far. I toyed around with spacing/padding but that did not produce any good results:
Skin skin = Resources.getSkin(Resources.SKIN_JSON);
container = new Table();
container.setSize(Resources.VIRTUAL_WIDTH, Resources.VIRTUAL_HEIGHT);
this.addActor(container);
Table table = new Table();
// table.debug();
final ScrollPane scroll = new ScrollPane(table, skin);
table.pad(10).defaults().expandX().space(4);
table.setSize(Resources.VIRTUAL_WIDTH, Resources.VIRTUAL_HEIGHT);
container.add(scroll).expand().fill().colspan(1);
container.row().space(10).padBottom(10);
Image background = new Image(Resources.getAtlas(Resources.SKIN_ATLAS).findRegion("main-panel-horz"));
container.setBackground(background.getDrawable());
TextButton button1 = new TextButton("Button1", skin);
table.add(button1);
table.row();
TextButton button2 = new TextButton("button2", skin);
table.add(button2);
table.row();
TextButton button3 = new TextButton("button3", skin);
table.add(button3);
table.row();
TextButton button4 = new TextButton("button4", skin);
table.add(button4);
What you need to do is pad the outer table to get its contents to fit in the region of the background that you would like. (Or you could alternatively pad the cell that you put the scroll pane in.)
If you use a 9-patch drawable for the background, the padding of the outer table will be done for you automatically. You could also specify a TextureRegionDrawable in your skin Json and use that as the background. That would also allow you to pad the table automatically.
You can easily get texture region drawables from the skin with skin.getDrawable(drawableName);--no need to create an intermediate Image just to create a drawable out of a region.
Here's how you would create a TextureRegionDrawable with explicit padding in json:
com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable: {
main-panel-horz-padded: { region: main-panel-horz, leftWidth: 50, rightWidth: 50, topHeight: 50, bottomHeight: 50 }
},
Then in your code:
container.setBackground(skin.getDrawable("main-panel-horz-padded"));

how to show autocomplete in gwt in tabular format with multiple column?

Following is my code but it shows only one column in autocomplete but i want shows data in tabular foramte with multiple column[In short i want to show suggestion box in tabular formate]. how i can do that?
Thanks in advance Please suggest anything..
FlowPanel panel = new FlowPanel();
initWidget(panel);
final BulletList list = new BulletList();
list.setStyleName("token-input-list-facebook");
final ListItem item = new ListItem();
item.setStyleName("token-input-input-token-facebook");
final TextBox itemBox = new TextBox();
itemBox.getElement().setAttribute( "style", "outline-color: -moz-use-text-color; outline-style: none; outline-width: medium;");
final SuggestBox box = new SuggestBox(getSuggestions(), itemBox);
box.getElement().setId("suggestion_box");
item.add(box);
list.add(item);

display numbers on pie chart

I've developed an android application to display a pie chart. I have used the achartengine library to do this.
With this code below I get the pie chart output with 3 portions labeled as mentioned in categorySeries. I want to display the percentage values on the pie diagram. How can i do this?
public static final GraphicalView getPieChartView(Context context,
CategorySeries dataset, DefaultRenderer renderer) {
checkParameters(dataset, renderer);
PieChart chart = new PieChart(dataset, renderer);
return new GraphicalView(context, chart);
}
private static void checkParameters(CategorySeries dataset,
DefaultRenderer renderer) {
if (dataset == null
|| renderer == null
|| dataset.getItemCount() != renderer
.getSeriesRendererCount()) {
throw new IllegalArgumentException(
"Dataset and renderer should be not null and the dataset number of items should be equal to the number of series renderers");
}
}
and this is my onCreate method
Bundle bundle = getIntent().getExtras();
int highc = bundle.getInt("high");
int lowc = bundle.getInt("low");
int medc = bundle.getInt("medium");
RelativeLayout layout = (RelativeLayout) findViewById(R.id.relativestatsLayout);
TextView message = (TextView) findViewById(R.id.statText);
message.setText("\n\n\tTickets Summary");
message.setGravity(50);
//layout.addView(message);
//setContentView(message);
int[] colors = new int[] { Color.rgb(255, 0, 0),Color.rgb(220, 51,51), Color.rgb(255, 191, 0) };
DefaultRenderer renderer = buildCategoryRenderer(colors);
CategorySeries categorySeries = new CategorySeries("Tickets Chart");
categorySeries.getTitle();
categorySeries.add("critical", highc);
categorySeries.add("major ", medc);
categorySeries.add("minor ", lowc);
layout.addView(getPieChartView(this, categorySeries, renderer));
}
protected DefaultRenderer buildCategoryRenderer(int[] colors) {
DefaultRenderer renderer = new DefaultRenderer();
for (int color : colors) {
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(color);
renderer.addSeriesRenderer(r);
}
return renderer;
}
It is possible using achartengine. I have faced the same problem and found the answer now.
Use the 1.1.0-rc2 version of achart engine. You can download it here: http://www.achartengine.org/download/
This tutorial (http://wptrafficanalyzer.in/blog/android-drawing-pie-chart-using-achartengine/) helps you to create pie chart using achartengine.
Add this line to your code to display the %of distribution in the Pie chart
defaultRenderer.setDisplayValues(true);
Reference: How to set different values for Legend and Labels in piechart While I am using Chart Engine in android
Im not sure if you still have this issue. But if your pie chart is fairly simple, you should consider drawing it your self rather using a library for it.
This might help a bit.
https://github.com/blessenm/PieChartDemo

Categories