Anylogic using state charts to travel - java

I am very new to Anylogic, and I want to model this process that doesn't seem too difficult. However, I really have no idea as to how to go about it. I also do not have a background in Java, so the coding bit is new to me as well.
I have the following state chart within an agent called a "picker":
I have a list of items in a warehouse in an excel sheet the columns are "Items, x-coordinate, y-coordinate" which is already in the model (roughly 10 rows). I want to pull the x-coordinates and y-coordinates from all the items listed in that excel file in the "getList" state. Next I want the "picker" to travel to each of those locations one-by-one until every item has been picked. The branch is asking "Do you have all the items?" If yes, it will continue to the "done" state.
Thank you in advance!

Related

Showing a counter dynamically for JList items highlighted

I have a program that I created for work. This program takes an uploaded file, reads it, and puts the data into a JList in the GUI. The GUI actually has two lists and the user is able to move items between the left and right list by highlighting them like usual with a JList and then hitting an arrow to move the items. The lists are multiple-interval selection.
One small addition I would like to add is some type of counter that shows the user how many items they have selected before they actually move them between lists. This would need to be dynamic so if the user holds control down and begins clicking the counter will continue to update the number of highlighted items.
As the lists are often quite large and a user might need to move an odd number of transactions between the lists (Think 300 transactions in left list and the user needs to move exactly 50) it would be beneficial to have this counter.
Can anyone think of how this could be done? I'm not sure how to add an action listener to just clicking on the items. Please also let me know if I need to elaborate any more.
Generally my question is can I create an action listener just for when a user clicks a item in a JList that updates a counter for the current selected indices? Also it would need to change when they no longer have selected an indice.
Register a ListSelectionListener with your JList.
The listener could simply query how many rows are selected and update the number in the panel to that. Perhaps use getSelectedValues().size().
http://docs.oracle.com/javase/8/docs/api/javax/swing/JList.html#addListSelectionListener-javax.swing.event.ListSelectionListener-

How to make add/remove item in list view modify variables (int and double) in Android

I'll keep this short. I am creating an Android program to allow users to create test mech builds outside of a video game in order to determine if their build is possible in game before dropping money.
Currently, a user can click "add modules" to choose between a list of items in a dialog to populate the list view. Each mech is limited to certain variables. Such as weight, slots open, hard points, etc. Once your mech weighs so much for instance, the part cannot be added.
I am looking for a way to populate the list and change variables depending on the part chosen (I'm pretty sure a simple if/else statement will work here) and more importantly I am looking for a way to allow the user to click a list item and remove it from list along with removing the added change to the variables (weight, slots, etc). (example: Part A increases tonnage from 0/100 to 10/100 tons. User removes part A and tonnage drops to 0/100 again).
Thanks in advance!
Visual:
Screenshot I do not have the rep to post images.

graphs in javaFX?

Is anyone familiar with the graphs and charts availability in javaFX?
I know how to create a bar graph but I have some doubts..
I'm creating a bar graph with the tutorial provided by Oracle, but it is taking the values on y-axis that are provided in the program itself. So every time you run it, it'll display a graph with the same set of values.
But what I want is the graph should be able to read the values from a table in Ms access and then display the graph according to the values from table ,so that every time I run it, it'll be showing the values currently in the database.
Is it possible?
Please let me know if there's a way of achieving this. There must be a way else what's the point of having these graphs and charts in javaFX if they're only going to take static values.
Please let me know..
Thanks..
Scenario
I have a table in ms access with 2 columns "blood group" and "no.of units".
see now the no of units in a blood bank keeps varying when a patient reuires some units of a blood group or when a hospital adds up units to it's blood bank.
so what i want is that graph should be able to read the "no.of units " from the table and display the level of each blood group accordingly.so even when the column "no of units" gets modified due to certain operation when i click on a button it should be able to display the graph with the current values of each blood group from the table..
Now can you tell how should i do it ??
Thanks.
You must have used the following site to go through the documentation on BARCHART IN JAVAFX
http://docs.oracle.com/javafx/2/charts/bar-chart.htm
Over here, when we are filling series1, using series1.getData().add(), instead of passing hardcoded values, you can pass the values that you have fetched from the database.
You can do the same thing for series2, series3.. As many series as you want to make ! Hope things are clear for you, or feel free to comment ! :)
-AA

Slow redraw of TableViewer when changing input object

In my project, I have a TableViewer which displays about 1k rows of data from database. The ContentProvider is an ArrayContentProvider.
When I change input the List (setInput() on TableViewer object) to another one with the same amount of data, everything is Ok. But when I want to update it with List<T> with different size than the previous one, the application freezes for about 10x the time of changing with same amount of data.
The first list has a size of 1k, and the second list a size of about 960. Execution freezes directly on setInput() method.
Does anybody know why this happens?
I think the reason is that when you set a List with a different size the whole native TableItems are recreated. So to speed up your table you should use a SWT.Virtual style table. With virtual table only the tableitems which are displayed are created. The others are created when you scroll.
See http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/examples/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet029VirtualTableViewer.java for an example.

sorting a JTable using a data vector

I got stuck with a performance problem while writing my program and I need your help! :)
I'm using a JTable to view test results taken from a vector I made and it has 4 columns in it. When I click on a row the details from a saved txt file of that test are shown in a child window. Also, when I click on the columns header the event sends the vector to a function that sorts it according to the pressed column. Every time a new value needs to be entered the sorting function is called again.
My program works fine with a small number of rows. But, when I enter say, 150 rows, every time I enter a new row the Table flicks (the sort probably takes a lot of time), but I have to keep the vector synchronized with the jable because of the "push to view the result" option.
I would really appreciate some help with this.
thanks
You shouldn't have to do any sorting yourself. JTable supports sorting natively, and has the convertRowIndexToModel and convertRowIndexToView methods to go from the view index to the model index and vice-versa.
See http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#sorting.
Use JTable's internal sorter (DefaultRowSorter). Do not re-create the vector which holds the data - use Vector's add() method to add new records. In many years of Java GUI development I haven't seen a single case where I had to keep records in the TableModel sorted. Make sure getColumnClass() returns a proper type, so the default sorter knows how to sort the column, and that is all.

Categories