Create printable daily schedule/document with Java - java

I have to create a java program that builds a "tidy" daily schedule for a sports arena.
The program takes in an excel file with a list of "untidy" daily bookings with the following information:
Start Time
End Time
Court
Client
I can read in this information and store it in "BookingObjects".
My question is this:
What is an elegant way to create a printable schedule output, similar to schedules displayed by Microsoft Outlook for example, with time as the rows and which court the booking is on in the columns. The schedule does not need to be interactive, just needs to be printable through the program's GUI and if it can be displayed within the GUI this is also a bonus?

We've recent made the move to Jasper Reports, the main reason was we were producing the reports in PDF, Excel and to the printer, all of which had to execute through different code and different libraries. Jasper Reports has allowed us to go through a single engine.
While not perfect, it does an outstanding job across different export options.
It does have a small learning curve, but the basics allow you to deliver a List of objects which you can then access from within the report and populate your view.
Equally, you can simply connect a SQL data source to it directly

Printing is one of the sore spots in Java. What you can try is create a UI with a table (see the Swing trail for examples) and then print that table.
The problems will start when the table doesn't fit on a single page of paper. If it's longer, then some lines will be printed on the margin (half of it will appear on the previous page and the lower half on the next page). If it's wider, ... let's not go there.
Alternatively, you can try to create a PDF using tools like JasperReports or BIRT. These work better but it will take some time to learn how they work.

Related

how can three cells work in parallel the incoming workpiece carriers in Analogic?

I want to create a conveyor line where three cells do the same work in parallel to reduce the cycle time.
Workflow:
Workpiece carrier = WT: 12 pieces
3x cells
The WT should always be directed to the cell that is free or the work process is most likely to finish.
Since I have just started to get to learn about Anylogic, I am having a hard time setting the correct commands.
If someone has an idea of how to reach my goal I would be very grateful!
Review the implementation in the Solar Panel Production Line Example model inside the AnyLogic help, or download the source form the AnyLogic Cloud
https://cloud.anylogic.com/model/29d54a61-aaac-4c47-8e50-941c0f5bb36e?mode=SETTINGS
Easiest would be to use a select output and base the selection of the exit from the select output on the condition of whether one of the cells are busy or not
In your example, you need to replace the code of randomFrom(collection) with a function to check if a cell is busy or not. Since you don't have the cells in your example I cant give you the code. But try it yourself and if you cant manage after reviewing the example model then post a new question

Capturing table data from Tableau dashboards in Java

Is there a way to automatically capture and store data from a tableau dashboard without access to the server.
I'm trying to automate a lot of our weekly audits (i.e. look at the dashboard, count the number of rows on a table, sum up the values in the last column, send out an email to everyone in the same template every week). I need basic functionality such as counting rows and pulling values from certain cells.
I do not have access to tabcmd (corporate blah blah).
I've previously automated Salesforce stuff in Selenium, however, the tableau dashboard is a visualization and not a web element.
I have investigated a few potential routes and was wondering if anyone else could chime in on the best way to approach this (or suggest another).
Use an OCR package to try and recognize values and sum up rows
I somehow automate the report downloading process so I can turn all the data into an excel/CSV file which I can play within Java
Use RPA tool such as UIPath (don't have much experience with the functionality but it seems like it could do it?)

Java save simple Data

i need to save data from an java desktop application. The main part of the Data are the texts of around 50 labels. Which are spread over 5 Java GUI-classes. The Rest are some simple application settings.
Now i am quit unsure about how to safe these data. A friend told me to use Random access Data and to write some kind of "serializable" object. At the moment i am using a .txt and a fileReader/writer. But this seemes impractical for 50-100 Data if your want to search the position in the .txt by every update. This is my same problem with random access data.
i thought about using some kind of embedded DB like "h2" but i dont now if this is to much and too complicated for such a small programm.
An other question is how do i put the text of all labels at the programm start. one way i am thinking about is to have a big list of all labels with determind positions and after reading the data from whatever to go over this list and set the labes. An other way would be to give every Label an id.
But maybe there is a much better way. But i dont now how to access the labels by names read from the data.
For saving serializable objects. Can i safe all the gui-object or do i need to combine se data in one class?
maybe someone could give a nice advise =)
For such a small number of labels, I would just keep all data in memory. On app initialization load the file and on every edit write the entire file from scratch
(If you are concerned about reliability in the face of power loss and random crashes during write you need to be careful here. For example, write the new data to a different file, fsync() then atomically rename the new file to the desired filename.)
I'm not sure I understand your serialization problem -- but it seems like you have some sort of language translation layer that tells the gui elements what to display. If so, then yes - I would store the labels in a central class (say LablesMap) and have the other classes refer to data in that class using some constant keys. E.g.,
myButton.setText(labelsMap.get(CANCEL_BUTTON_LABEL)
where CANCEL_BUTTON_LABEL is some constant or enum value.

Java Swing save and load workspace/settings

I have a Java Swing application that contains a bunch of frames which in turn predominantly contains tables that display large amounts of data. Since it is always a hassle and its time consuming to arrange all windows and tables on startup, I would like to implement 'workspace'-functionality so that the user can save a setup of preference and on startup choose to automatically load the stored workspace to have all windows and tables appear as previously saved. Specifically, the settings that I wish to store in a workspace are:
Active windows (JFrame) and their sizes and positions on screen
Table settings, incl selected columns, column order, column width, sorting, filtering
Does anyone know of a smart and easy way to accomplish this without the obvious, and what seems like a very complex and cumbersome, solution of iterating over all open windows and saving each piece of information with the Preferences api? Thanks
In this case, the obvious solution, java.util.prefs.Preferences, is probably the correct one. RCPrefs from this game is a simple example that demonstrates saving a variety of data types, including enum. The exact implementation is highly dependent on the application. While tedious, it needn't be especially complex. For expedience, the example uses static methods; frame and table preferences are probably worth a class each.

JasperReport & Filling Components

JasperReports newbie here. I have read the tutorial and the quick reference and read up on a number of articles regarding JR, and have now been playing around with the iReport report designer for a day or so.
I think the last major set of concepts I am choking on have to do with the relationship between chart components and their data. Although it is easy to find definitions for each of these, there seems to be very little practicle documentation showing how they relate to one another in a meaningful application.
Report Fields
Report Prameters
Report Variables
Datasets
By playing around with iReport it seems that Fields, Parameters and Variables can exist at the report-level, as well as being placed inside of Datasets. But my understanding of when something is a Field vs. Parameter vs. Variable is very fuzzy, and my understanding of how they relate to Datasets is also very shaky.
Using Datasets as a slight segue, I'm having a tough time seeing the "forest through the trees" with how chart components (such as pie charts, tabls, etc.) get "fed" or "injected with" their data.
Soo... I thought of an example that, if answered, would tie everything together for me (I believe!). Let's say I had two chart components, a text field and a pie chart. I want the pie chart to appear below the text field like so:
The author of this report is: <value supplied by the data source>
<pie chart here>
So, at "fill time" (I think I'm using that correctly...), the report will be "filled" with the name of the report's author (a String), as well as a pie chart comprised of 2 pie slices: 1 slice with a value of 75 with a label/key of "Eloi" and a 2nd slice with a value of 25 and a label/key of "Morlocks". If I am not using the correct JR terminology here, what I am trying to achieve is a fill-time pie chart with two slices: an "Eloi" slice consuming 75% of the chart, and a "Morlocks" slice consuming 25% of the chart.
If someone can explain or give code (Java/JRXML) snippets for how to set this kind of chart up, I think it will help connect all the dots and help me understand how components get filled with data. Thanks in advance for any and all help!
Think of parameters as things that the end user supplies to the report at runtime. For example, you supply a StartDate and an EndDate that will get used in a query. The start date that you are interested in is something you know, it's not provided by the data source. (There are variations on this idea: maybe your application knows things about you based on your login, and it supplies these as parameters. But again, these are things known before the report is executed.)
Think of the fields as the data that comes back from your data source. This is the stuff that you want to learn. For example, you run a query like this:
select political_group, gullibility from mytable where the_date > $P{StartDate}
Presumably you would input a value of '802701' for the StartDate and then get results like this:
$F{political_group} $F{gullibility}
Eloi 75
Morlock 25
Think of variables as a way to manipulate this raw data. They can calculate totals and subtotals as well as line-by-line calculations like string manipulation or more complex things like running totals.
Take a look at this pie chart report I posted a couple of years ago: http://mdahlman.wordpress.com/2009/05/02/limiting-pie-pieces/
It has the main ideas you want. I put the title directly into the chart rather than as a separate field. That would be a very simple change. Likewise, you could change the title to "The author of this report is: $P{TheAuthor}" and then pass that param to the report at runtime.
Using a field in the report title rather than a parameter is possible also. But typically it doesn't make sense. The fields will have many values in the data set. Which one belongs in the title? In the case above "Eloi" and "Morlock" are fields, and they really don't make sense in the report title. (You can imagine special cases, of course. You could concatenate all of the political_group values into a single string and put that in the report title. But in an overwhelming majority of cases this won't be reasonable.)
Good luck.

Categories