Advanced row/grid level supression on multiple pages.
Hi,
I have defined a report with one dimension in Page axis. The dimension in Page axis has 10 members.
I have defined advanced supression at row level (also tried grid level) like
"Supress row if data value in a particular column is > 5."
This supression works only for the first member in the page axis, i.e 1st page. All other pages (starting form page 2 to last page) do not take this supression criteria.
Hyperion Financial Reporting Studio V9.3.1
Appreciate your thoughts.
Thanks.
I think this works... kinda
1. I have a "list" that allows the selection of the item to edit.
2. That list opens a page that is the "header" page for a tab set.
3. Each page in the tab set uses the same "ID" to read the record and display the columns. That is how it would work if the list called each individual page.
4. I modified the "slave" tabs to have the "ID" of the "header" page.
This displays the correct data on each page. And it looks like the "apply changes" button saves the changes on the page.
Caveats inlclude (I think as I haven't done exhaustive testing"
1. "apply changes" must be done at each page where there were changes or they would be lost.
2. The first dispaly of the page is blank. Clicking on the tab a second time displays the data. This is true if it is the first time a user selects a record in a session (the "slave" tabs are blank) or if it is a subsequent record update (the "slave" tabs have the last records data.
Thoughts... is this really boring to everyone but me?
Sam
Similar Messages
-
ALV GRID capable to trigger multiple pages
Hi All,
I need some help on ALV grid display.
My requirement is :
I have got all my required data inside my final o/p internal table.
The first 2 columns of my o/p int table are MATNR (material no) and Location.
Now whenever this combination of MATNR and Location changes, I need to trigger a new page.
Also at te top of each page I will be displaying the material and location number.
I have to achieve this using ALV GRID display. I have tried this out in ALV LIST and its working but its not working incase ALV GRID is used.
I am giving an example of the scenerio for clear understanding
o/p Intarnal table (I_out)
<u>MATNR</u> <u>Location</u> <u>Details1</u> <u>Details 2</u> <u>Details3</u> ............
23 BE01 abc cde xyz
23 BE01 pqr efg rst
24 BE01 pqr efg rst
24 BE01 pqr efg rst
25 BE02 pqr efg rst
In this case, the 1st two records are for the same material and location details,
The 3rd and 4th record are for same material and Location details
and the last record is for a different combination of the material and location.
Hence the required o/p will be: (in ALV GRID display)
Material : 23
Location: BE01
<u>Detail1</u> <u>Detail2</u> <u>Detail3</u> .....................
abc cde xyz
pqr efg rst
Material : 24
Location: BE01
<u>Detail1</u> <u>Detail2</u> <u>Detail3</u> .....................
pqr efg rst
pqr efg rst
Material : 25
Location: BE02
<u>Detail1</u> <u>Detail2</u> <u>Detail3</u> .....................
pqr efg rst
This is the o/p format that i need to achieve and that too in ALV GRID display.
Please suggest suitable ways.Dear Ramesh,
If I understand you correctly, you want to display a hierarchial form of display. However this won't be possible in ALV GRID Display as the maximum number of rows that you can set would be three. There by restricting you from displaying further information.
For further information on the same please refer to the following link:
Re: alv report
Best Regards,
Rajesh
<b>Please reward points if found helpful.</b> -
Multiple pages that edit a single row
I have searched on tabs and editing a single row using multiple pages and I am confused. I don't want to use java as I am trying to not learn that too...
What I am trying to do sounds like it has been explained before but let me do this again...
I have a record that is too large to fit on a single screen. This makes for a cumbersome entry process. The record is actually broken into four "logical" chunks. Main, Sub1, Sub2 and Sub3.
I have made a list that will allow the record to be selected and call the first logical page... L1.
I have made tabs that show all the pages and allow me to navigate between them quickly.
When I get to L1 all the data is there. I may not change any data on that page and go directly to L2 through L4. However the record is not brought forward onto those pages. So the pages are not related (and I don't have the terminology right I know :) and I could "link" the pages. So here is what I would like the application to do;
1. Display a list and allow the user to select the record to edit.
2. Upon edit go to the first page (tab).. this works
3. Allow the user to select a tab and the page displays the data for the record selected
4. Allow the user to complete the edits and save the record. Upon save the user is returned to the list in step 1.
I was thinking there are several ways to do it... but I was hoping someone could save me a bunch of trial and error (emphasis on the error) ...
1. When navigating off the page save the record, pass the key and re-read the record... ugly huh?
2. Pass all the session data for the record over to the next screen. Is that possible? e.g pxx_field1 = pyy_field1
The the question was does a template with two level tabs keep the record data between tabs?
Any help is greatly appreciated.
SamI think this works... kinda
1. I have a "list" that allows the selection of the item to edit.
2. That list opens a page that is the "header" page for a tab set.
3. Each page in the tab set uses the same "ID" to read the record and display the columns. That is how it would work if the list called each individual page.
4. I modified the "slave" tabs to have the "ID" of the "header" page.
This displays the correct data on each page. And it looks like the "apply changes" button saves the changes on the page.
Caveats inlclude (I think as I haven't done exhaustive testing"
1. "apply changes" must be done at each page where there were changes or they would be lost.
2. The first dispaly of the page is blank. Clicking on the tab a second time displays the data. This is true if it is the first time a user selects a record in a session (the "slave" tabs are blank) or if it is a subsequent record update (the "slave" tabs have the last records data.
Thoughts... is this really boring to everyone but me?
Sam -
Print JTable with Multiple pages and rows
I took the printing example at http://java.sun.com/developer/onlineTraining/Programming/JDCBook/advprint.html#pe and modified it a bit to include the following:
1) To Print Multiple pages
2) To wrap lines that is too long for the column
3) To print with a more proffesional style, so that it doesn't look like a screen capture is printed
4) To align the numbers to the right and center column headings
import javax.swing.*;
import javax.swing.table.*;
import java.awt.print.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.Dimension;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import java.text.*;
public class Report implements Printable
private final int LEFT_ALIGN = -1;
private final int CENTER_ALIGN = 0;
private final int RIGHT_ALIGN = 1;
private JFrame frame;
private JTable tableView;
private String lastPrintDate;
private Font defaultFont;
private Font headerFont;
private Font footerFont;
private int headerHeight;
private int footerHeight;
private int cellBuffer = 5;
private boolean first_pass;
private ArrayList pages;
public Report()
frame = new JFrame("Sales Report");
frame.addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
final String[] headers =
"ID",
"Description",
"open price",
"latest price",
"End Date",
"Quantity"
int count = 0;
final Object[][] data =
{new Integer(count++), "Box of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of Biros ppppppppppppppp", "1.00", "4.99", new Date(), new Integer(200000)},
{new Integer(count++), "Blue Biro", "0.10", "0.14", new Date(), new Integer(1)},
{new Integer(count++), "legal pad", "1.00", "2.49", new Date(), new Integer(1)},
{new Integer(count++), "tape", "1.00", "1.49", new Date(), new Integer(1)},
{new Integer(count++), "stapler", "4.00", "4.49", new Date(), new Integer(1)},
{new Integer(count++), "Box of Biros", "1.00", "4.99", new Date(), new Integer(2)},
{new Integer(count++), "Blue Biro", "0.10", "0.14", new Date(), new Integer(1)},
{new Integer(count++), "legal pad", "1.00", "2.49", new Date(), new Integer(1)},
{new Integer(count++), "tape", "1.00", "1.49", new Date(), new Integer(1)},
{new Integer(count++), "stapler", "4.00", "4.49", new Date(), new Integer(1)},
{new Integer(count++), "Box of Biros", "1.00", "4.99", new Date(), new Integer(2)},
{new Integer(count++), "Blue Biro", "0.10", "0.14", new Date(), new Integer(1)},
{new Integer(count++), "legal pad", "1.00", "2.49", new Date(), new Integer(1)},
{new Integer(count++), "tape", "1.00", "1.49", new Date(), new Integer(1)},
{new Integer(count++), "stapler", "4.00", "4.49", new Date(), new Integer(1)},
{new Integer(count++), "Box of Biros", "1.00", "4.99", new Date(), new Integer(2)},
{new Integer(count++), "Blue Biro", "0.10", "0.14", new Date(), new Integer(1)},
{new Integer(count++), "legal pad", "1.00", "2.49", new Date(), new Integer(1)},
{new Integer(count++), "tape", "1.00", "1.49", new Date(), new Integer(1)},
{new Integer(count++), "stapler", "4.00", "4.49", new Date(), new Integer(1)},
{new Integer(count++), "Box of Biros", "1.00", "4.99", new Date(), new Integer(2)},
{new Integer(count++), "Blue Biro", "0.10", "0.14", new Date(), new Integer(1)},
{new Integer(count++), "legal pad", "1.00", "2.49", new Date(), new Integer(1)},
{new Integer(count++), "tape", "1.00", "1.49", new Date(), new Integer(1)},
{new Integer(count++), "stapler", "4.00", "4.49", new Date(), new Integer(1)},
{new Integer(count++), "Box of Biros", "1.00", "4.99", new Date(), new Integer(2)},
{new Integer(count++), "Blue Biro", "0.10", "0.14", new Date(), new Integer(1)},
{new Integer(count++), "legal pad", "1.00", "2.49", new Date(), new Integer(1)},
{new Integer(count++), "tape", "1.00", "1.49", new Date(), new Integer(1)},
{new Integer(count++), "stapler", "4.00", "4.49", new Date(), new Integer(1)},
{new Integer(count++), "Box of Biros", "1.00", "4.99", new Date(), new Integer(2)}
TableModel dataModel = new AbstractTableModel()
public int getColumnCount() { return headers.length; }
public int getRowCount() { return data.length;}
public Object getValueAt(int row, int col)
return data[row][col];
public String getColumnName(int column)
return headers[column];
public Class getColumnClass(int col)
return getValueAt(0,col).getClass();
public boolean isCellEditable(int row, int col)
return (col==1);
public void setValueAt(Object aValue, int row, int column)
data[row][column] = aValue;
tableView = new JTable(dataModel);
JScrollPane scrollpane = new JScrollPane(tableView);
scrollpane.setPreferredSize(new Dimension(500, 80));
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(BorderLayout.CENTER,scrollpane);
frame.pack();
JButton printButton= new JButton();
printButton.setText("print me!");
frame.getContentPane().add(BorderLayout.SOUTH,printButton);
// for faster printing turn double buffering off
RepaintManager.currentManager(frame).setDoubleBufferingEnabled(false);
printButton.addActionListener( new ActionListener()
public void actionPerformed(ActionEvent evt)
doPrint();
frame.setVisible(true);
* Reset variables before printing
private void prepareForPrint()
pages = new ArrayList();
first_pass = true;
* Display a print dialog with some hardcoded defaults
* The print fonts are also hardcoded
public void doPrint()
try
String jobName = "Java Report";
defaultFont = new Font("Arial", Font.PLAIN, 8);
footerFont = new Font("Arial", Font.PLAIN, 6);
headerFont = new Font("Arial", Font.BOLD, 10);
PrinterJob prnJob = PrinterJob.getPrinterJob();
prnJob.setPrintable(this);
PrintRequestAttributeSet prnSet = new HashPrintRequestAttributeSet();
prnSet.add(new Copies(1));
prnSet.add(new JobName(jobName, null));
prnSet.add(MediaSizeName.ISO_A4);
PageFormat pf = prnJob.defaultPage();
pf.setOrientation(java.awt.print.PageFormat.PORTRAIT);
prnJob.setJobName(jobName);
PrintService[] services = PrinterJob.lookupPrintServices();
if (services.length > 0)
if (prnJob.printDialog(prnSet))
* Get print date
String dateFormat = "dd/MM/yyyy HH:mm:ss";
DateFormat m_DateFormat = new SimpleDateFormat(dateFormat);
lastPrintDate = m_DateFormat.format(new Date()).toString();
prepareForPrint();
prnJob.print(prnSet);
else
JOptionPane.showMessageDialog(frame, "No Printer was found!!", "Printer Error", JOptionPane.ERROR_MESSAGE);
return;
catch (PrinterException e)
e.printStackTrace();
public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException
* Check if this is the first time the print method is called for this print action.
* It is not guaranteed that the print will be called with synchronous pageIndex'es,
* so we need to calculate the number of pages and which rows appear on which pages.
* Then the correct page will be printed regardless of which pageIndex is sent through.
if (first_pass)
calcPages(g, pageFormat);
first_pass = false;
// Stop printing if the pageIndex is out of range
if (pageIndex >= pages.size())
return NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.black);
// The footer will be one line at the bottom of the page, cater for this.
g2.setFont(footerFont);
footerHeight = g2.getFontMetrics().getHeight() + g2.getFontMetrics().getDescent();
g2.setFont(defaultFont);
FontMetrics fontMetrics = g2.getFontMetrics();
int fontHeight = fontMetrics.getHeight();
int fontDescent = fontMetrics.getDescent();
double pageHeight = pageFormat.getImageableHeight() + pageFormat.getImageableY();
double pageWidth = pageFormat.getImageableWidth();
double tableWidth = (double) tableView.getColumnModel().getTotalColumnWidth();
// Shrink or expand the table to fit the page width
double scale = pageWidth / (tableWidth+ (cellBuffer * tableView.getColumnCount()));
// Calculate the width in pixels for each column
double[] columnWidths = new double[tableView.getColumnCount()];
for(int i = 0; i < tableView.getColumnCount(); i++)
columnWidths[i] = (double)tableView.getColumnModel().getColumn(i).getWidth() * scale;
// Reset the view to the start of the page
g2.translate(0, 0);
// Draw a rectangle to see the printable area
g2.draw3DRect((int)pageFormat.getImageableX(),
(int)pageFormat.getImageableY(),
(int)pageFormat.getImageableWidth(),
(int)pageFormat.getImageableHeight(),
false);
// Calculate the header height
g2.setFont(headerFont);
fontMetrics = g2.getFontMetrics();
// Print the headers and retreive the starting position for the data
int next_row = printLine(g2, pageFormat, fontMetrics, -1, (int)pageFormat.getImageableY() + fontHeight, columnWidths);
g2.setFont(defaultFont);
fontMetrics = g2.getFontMetrics();
// Start printing the detail
ArrayList page = (ArrayList)pages.get(pageIndex);
int start = ((Integer)page.get(0)).intValue();
int end = ((Integer)page.get(1)).intValue();
for (int i = start; i <= end; i++)
next_row = printLine(g2, pageFormat, fontMetrics, i, next_row, columnWidths);
// Print the footer
g2.setFont(footerFont);
String pageFooter = "Page " + (pageIndex + 1) + " - " + lastPrintDate;
g2.drawString(pageFooter,
(int)pageFormat.getWidth() / 2 - (fontMetrics.stringWidth(pageFooter) / 2),
(int)(pageHeight - fontDescent));
return PAGE_EXISTS;
* We can't guarantee that the same amount of rows will be displayed on each page,
* the row heights are dynamic and may wrap onto 2 or more lines.
* Thus we need to calculate the height of each row and then test how may rows
* fit on a specific page. eg. Page 1 contains rows 1 to 10, Page 2 contains rows 11 to 15 etc.
public void calcPages(Graphics g, PageFormat pageFormat) throws PrinterException
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.black);
// The footer will be one line at the bottom of the page, cater for this.
g2.setFont(footerFont);
footerHeight = g2.getFontMetrics().getHeight() + g2.getFontMetrics().getDescent();
g2.setFont(defaultFont);
FontMetrics fontMetrics = g2.getFontMetrics();
int fontHeight = fontMetrics.getHeight();
int fontDescent = fontMetrics.getDescent();
double pageHeight = pageFormat.getImageableHeight() - fontHeight;
double pageWidth = pageFormat.getImageableWidth();
double tableWidth = (double) tableView.getColumnModel().getTotalColumnWidth();
// Shrink or expand the table to fit the page width
double scale = pageWidth / (tableWidth+ (cellBuffer * tableView.getColumnCount()));
// Calculate the width in pixels for each column
double[] columnWidths = new double[tableView.getColumnCount()];
for(int i = 0; i < tableView.getColumnCount(); i++)
columnWidths[i] = (double)tableView.getColumnModel().getColumn(i).getWidth() * scale;
// Calculate the header height
int maxHeight = 0;
g2.setFont(headerFont);
fontMetrics = g2.getFontMetrics();
for (int j = 0; j < tableView.getColumnCount(); j++)
String value = tableView.getColumnName(j).toString();
int numLines = (int)Math.ceil(fontMetrics.stringWidth(value) / columnWidths[j]);
if (numLines > maxHeight)
maxHeight = numLines;
headerHeight = g2.getFontMetrics().getHeight() * maxHeight;
g2.setFont(defaultFont);
fontMetrics = g2.getFontMetrics();
int pageNum = 0;
int bottom_of_page = (int)(pageFormat.getImageableHeight() + pageFormat.getImageableY()) - footerHeight;
int prev_row = 0;
int next_row = (int)pageFormat.getImageableY() + fontHeight + headerHeight;
int i = 0;
ArrayList page = new ArrayList();
page.add(new Integer(0));
for (i = 0; i < tableView.getRowCount(); i++)
maxHeight = 0;
for (int j = 0; j < tableView.getColumnCount(); j++)
String value = tableView.getValueAt(i, j).toString();
int numLines = (int)Math.ceil(fontMetrics.stringWidth(value) / columnWidths[j]);
if (numLines > maxHeight)
maxHeight = numLines;
prev_row = next_row;
next_row += (fontHeight * maxHeight);
// If we've reached the bottom of the page then set the current page's end row
if (next_row > bottom_of_page)
page.add(new Integer(i - 1));
pages.add(page);
page = new ArrayList();
page.add(new Integer(i));
pageNum++;
next_row = (int)pageFormat.getImageableY()
+ fontHeight
+ ((int)pageFormat.getHeight() * pageNum)
+ headerHeight;
bottom_of_page = (int)(pageFormat.getImageableHeight()
+ pageFormat.getImageableY())
+ ((int)pageFormat.getHeight() * pageNum)
- footerHeight;
//Include the current row on the next page, because there is no space on this page
i--;
page.add(new Integer(i - 1));
pages.add(page);
* Print the headers or a row from the table to the graphics context
* Return the position of the row following this one
public int printLine(Graphics2D g2,
PageFormat pageFormat,
FontMetrics fontMetrics,
int rowNum,
int next_row,
double[] columnWidths)
throws PrinterException
int lead = 0;
int maxHeight = 0;
for (int j = 0; j < tableView.getColumnCount(); j++)
String value = null;
int align = LEFT_ALIGN;
if (rowNum > -1)
Object obj = tableView.getValueAt(rowNum, j);
if (obj instanceof Number)
align = RIGHT_ALIGN;
value = obj.toString();
else
align = CENTER_ALIGN;
value = tableView.getColumnName(j);
int numLines = (int)Math.ceil(fontMetrics.stringWidth(value) / columnWidths[j]);
if (numLines > maxHeight)
maxHeight = numLines;
if (fontMetrics.stringWidth(value) < columnWidths[j])
// Single line
int offset = 0;
// Work out the offset from the start of the column to display alignment correctly
switch (align)
case RIGHT_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value)); break;
case CENTER_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value)) / 2; break;
default: offset = 0; break;
g2.drawString(value,
lead + (int)(pageFormat.getImageableX() + offset),
next_row);
else
for(int a = 0; a < numLines; a++)
//Multi-Line
int x = 0;
int width = 0;
for(x = 0; x < value.length(); x++)
width += fontMetrics.charWidth(value.charAt(x));
if (width > columnWidths[j])
break;
int offset = 0;
// Work out the offset from the start of the column to display alignment correctly
switch (align)
case RIGHT_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value)); break;
case CENTER_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value)) / 2; break;
default: offset = 0; break;
g2.drawString(value.substring(0, x),
lead + (int)(pageFormat.getImageableX() + offset),
next_row + (fontMetrics.getHeight() * a));
value = value.substring(x);
lead += columnWidths[j] + cellBuffer;
// Draw a solid line below the row
g2.draw(new Line2D.Double(pageFormat.getImageableX(),
next_row + (fontMetrics.getHeight() * (maxHeight - 1)) + fontMetrics.getDescent(),
pageFormat.getImageableY() + pageFormat.getImageableWidth(),
next_row + (fontMetrics.getHeight() * (maxHeight - 1)) + fontMetrics.getDescent()));
// Return the position of the row following this one
return next_row + (fontMetrics.getHeight() * maxHeight);
public static void main(String[] args)
new Report();
}Fixed some bugs and added a title. Just pass in a JTable and the class will do the rest.
import javax.swing.*;
import javax.swing.table.*;
import java.awt.print.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import java.text.*;
import java.math.*;
public class PrintJTable implements Printable
private final int LEFT_ALIGN = -1;
private final int CENTER_ALIGN = 0;
private final int RIGHT_ALIGN = 1;
private JFrame m_parent;
private String m_title;
private JTable tableView;
private String lastPrintDate;
private Font defaultFont;
private Font headerFont;
private Font footerFont;
private int headerHeight;
private int footerHeight;
private int cellBuffer = 5;
private boolean first_pass;
private ArrayList pages;
public PrintJTable(JFrame parent, JTable table)
m_parent = parent;
tableView = table;
doPrint();
public PrintJTable(JFrame parent, String title, JTable table)
m_parent = parent;
m_title = title;
tableView = table;
doPrint();
* Reset variables before printing
private void prepareForPrint()
pages = new ArrayList();
first_pass = true;
* Display a print dialog with some hardcoded defaults
* The print fonts are also hardcoded
public void doPrint()
try
String jobName = "Java Report";
defaultFont = new Font("Arial", Font.PLAIN, 8);
footerFont = new Font("Arial", Font.PLAIN, 6);
headerFont = new Font("Arial", Font.BOLD, 8);
PrinterJob prnJob = PrinterJob.getPrinterJob();
prnJob.setPrintable(this);
PrintRequestAttributeSet prnSet = new HashPrintRequestAttributeSet();
prnSet.add(new Copies(1));
prnSet.add(new JobName(jobName, null));
prnSet.add(MediaSizeName.ISO_A4);
PageFormat pf = prnJob.defaultPage();
pf.setOrientation(java.awt.print.PageFormat.PORTRAIT);
prnJob.setJobName(jobName);
PrintService[] services = PrinterJob.lookupPrintServices();
if (services.length > 0)
if (prnJob.printDialog(prnSet))
* Get print date
String dateFormat = "dd/MM/yyyy HH:mm:ss";
DateFormat m_DateFormat = new SimpleDateFormat(dateFormat);
lastPrintDate = m_DateFormat.format(new Date()).toString();
prepareForPrint();
prnJob.print(prnSet);
else
JOptionPane.showMessageDialog(m_parent, "No Printer was found!!", "Printer Error", JOptionPane.ERROR_MESSAGE);
return;
catch (PrinterException e)
e.printStackTrace();
public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException
* Check if this is the first time the print method is called for this print action.
* It is not guaranteed that the print will be called with synchronous pageIndex'es,
* so we need to calculate the number of pages and which rows appear on which pages.
* Then the correct page will be printed regardless of which pageIndex is sent through.
if (first_pass)
calcPages(g, pageFormat);
first_pass = false;
// Stop printing if the pageIndex is out of range
if (pageIndex >= pages.size())
return NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.black);
// The footer will be one line at the bottom of the page, cater for this.
g2.setFont(footerFont);
footerHeight = g2.getFontMetrics().getHeight() + g2.getFontMetrics().getDescent();
g2.setFont(defaultFont);
FontMetrics fontMetrics = g2.getFontMetrics();
int fontHeight = fontMetrics.getHeight();
int fontDescent = fontMetrics.getDescent();
double pageHeight = pageFormat.getImageableHeight() + pageFormat.getImageableY();
double pageWidth = pageFormat.getImageableWidth();
double tableWidth = (double) tableView.getColumnModel().getTotalColumnWidth();
// Shrink or expand the table to fit the page width
double scale = (pageWidth - (cellBuffer * tableView.getColumnCount())) / tableWidth;
// Calculate the width in pixels for each column
double[] columnWidths = new double[tableView.getColumnCount()];
double test = 0;
for(int i = 0; i < tableView.getColumnCount(); i++)
columnWidths[i] = (double)Math.floor(tableView.getColumnModel().getColumn(i).getWidth() * scale);
test += columnWidths;
// Reset the view to the start of the page
g2.translate(0, 0);
// Draw a rectangle to see the printable area
g2.draw3DRect((int)pageFormat.getImageableX(),
(int)pageFormat.getImageableY(),
(int)pageFormat.getImageableWidth(),
(int)pageFormat.getImageableHeight(),
false);
// Calculate the header height
g2.setFont(headerFont);
fontMetrics = g2.getFontMetrics();
// Print the headers and retreive the starting position for the data
int next_row = (int)pageFormat.getImageableY() + fontMetrics.getHeight();
if ((m_title != null) && (!m_title.equalsIgnoreCase("")))
g2.drawString(m_title,
(int)(pageFormat.getImageableX()),
next_row);
Color current_color = g2.getColor();
g2.setColor(Color.lightGray);
int y = next_row + fontMetrics.getDescent();
g2.draw(new Line2D.Double(pageFormat.getImageableX(),
y,
(pageFormat.getImageableY() + pageFormat.getImageableWidth()),
y));
g2.setColor(current_color);
next_row += fontMetrics.getHeight();
next_row = printLine(g2, pageFormat, fontMetrics, -1, next_row, columnWidths);
g2.setFont(defaultFont);
fontMetrics = g2.getFontMetrics();
// Start printing the detail
ArrayList page = (ArrayList)pages.get(pageIndex);
int start = ((Integer)page.get(0)).intValue();
int end = ((Integer)page.get(1)).intValue();
for (int i = start; i <= end; i++)
next_row = printLine(g2, pageFormat, fontMetrics, i, next_row, columnWidths);
// Print the footer
g2.setFont(footerFont);
String pageFooter = "Page " + (pageIndex + 1) + " - " + lastPrintDate;
g2.drawString(pageFooter,
(int)pageFormat.getWidth() / 2 - (fontMetrics.stringWidth(pageFooter) / 2),
(int)(pageHeight - fontDescent));
return PAGE_EXISTS;
* We can't guarantee that the same amount of rows will be displayed on each page,
* the row heights are dynamic and may wrap onto 2 or more lines.
* Thus we need to calculate the height of each row and then test how may rows
* fit on a specific page. eg. Page 1 contains rows 1 to 10, Page 2 contains rows 11 to 15 etc.
public void calcPages(Graphics g, PageFormat pageFormat) throws PrinterException
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.black);
// The footer will be one line at the bottom of the page, cater for this.
g2.setFont(footerFont);
footerHeight = g2.getFontMetrics().getHeight() + g2.getFontMetrics().getDescent();
g2.setFont(defaultFont);
FontMetrics fontMetrics = g2.getFontMetrics();
int fontHeight = fontMetrics.getHeight();
int fontDescent = fontMetrics.getDescent();
double pageHeight = pageFormat.getImageableHeight() - fontHeight;
double pageWidth = pageFormat.getImageableWidth();
double tableWidth = (double) tableView.getColumnModel().getTotalColumnWidth();
// Shrink or expand the table to fit the page width
double scale = (pageWidth - (cellBuffer * tableView.getColumnCount())) / tableWidth;
// Calculate the width in pixels for each column
double[] columnWidths = new double[tableView.getColumnCount()];
for(int i = 0; i < tableView.getColumnCount(); i++)
columnWidths[i] = (double)Math.floor(tableView.getColumnModel().getColumn(i).getWidth() * scale);
// Calculate the header height
int maxHeight = 0;
g2.setFont(headerFont);
fontMetrics = g2.getFontMetrics();
headerHeight = 0;
if ((m_title != null) && (!m_title.equalsIgnoreCase("")))
headerHeight = fontMetrics.getHeight();
for (int j = 0; j < tableView.getColumnCount(); j++)
String value = tableView.getColumnName(j).toString();
int numLines = (int)Math.ceil(fontMetrics.stringWidth(value) / columnWidths[j]);
if (numLines > maxHeight)
maxHeight = numLines;
headerHeight += g2.getFontMetrics().getHeight() * maxHeight;
g2.setFont(defaultFont);
fontMetrics = g2.getFontMetrics();
int pageNum = 0;
int bottom_of_page = (int)(pageFormat.getImageableHeight() + pageFormat.getImageableY()) - footerHeight;
int prev_row = 0;
int next_row = (int)pageFormat.getImageableY() + fontHeight + headerHeight;
int i = 0;
ArrayList page = new ArrayList();
page.add(new Integer(0));
for (i = 0; i < tableView.getRowCount(); i++)
maxHeight = 0;
for (int j = 0; j < tableView.getColumnCount(); j++)
String value = formatObject(tableView.getValueAt(i, j));
int numLines = (int)Math.ceil(fontMetrics.stringWidth(value) / columnWidths[j]);
if (numLines > maxHeight)
maxHeight = numLines;
prev_row = next_row;
next_row += (fontHeight * maxHeight);
// If we've reached the bottom of the page then set the current page's end row
if (next_row > bottom_of_page)
page.add(new Integer(i - 1));
pages.add(page);
page = new ArrayList();
page.add(new Integer(i));
pageNum++;
next_row = (int)pageFormat.getImageableY()
+ fontHeight
+ ((int)pageFormat.getHeight() * pageNum)
+ headerHeight;
bottom_of_page = (int)(pageFormat.getImageableHeight()
+ pageFormat.getImageableY())
+ ((int)pageFormat.getHeight() * pageNum)
- footerHeight;
//Include the current row on the next page, because there is no space on this page
i--;
page.add(new Integer(i - 1));
pages.add(page);
* Print the headers or a row from the table to the graphics context
* Return the position of the row following this one
public int printLine(Graphics2D g2,
PageFormat pageFormat,
FontMetrics fontMetrics,
int rowNum,
int next_row,
double[] columnWidths)
throws PrinterException
int lead = 0;
int maxHeight = 0;
for (int j = 0; j < tableView.getColumnCount(); j++)
String value = null;
int align = LEFT_ALIGN;
if (rowNum > -1)
Object obj = tableView.getValueAt(rowNum, j);
if (obj instanceof Number)
align = RIGHT_ALIGN;
value = formatObject(obj);
else
//align = CENTER_ALIGN;
value = tableView.getColumnName(j);
int numLines = (int)Math.ceil(fontMetrics.stringWidth(value) / columnWidths[j]);
if (numLines > maxHeight)
maxHeight = numLines;
if (fontMetrics.stringWidth(value) < columnWidths[j])
// Single line
int offset = 0;
// Work out the offset from the start of the column to display alignment correctly
switch (align)
case RIGHT_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value)); break;
case CENTER_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value)) / 2; break;
default: offset = 0; break;
g2.drawString(value,
lead + (int)(pageFormat.getImageableX() + offset),
next_row);
else
for(int a = 0; a < numLines; a++)
//Multi-Line
int x = 0;
int width = 0;
for(x = 0; x < value.length(); x++)
width += fontMetrics.charWidth(value.charAt(x));
if (width > columnWidths[j])
break;
int offset = 0;
// Work out the offset from the start of the column to display alignment correctly
switch (align)
case RIGHT_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value.substring(0, x))); break;
case CENTER_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value.substring(0, x))) / 2; break;
default: offset = 0; break;
g2.drawString(value.substring(0, x),
lead + (int)(pageFormat.getImageableX() + offset),
next_row + (fontMetrics.getHeight() * a));
value = value.substring(x);
lead += columnWidths[j] + cellBuffer;
// Draw a solid line below the row
Color current_color = g2.getColor();
g2.setColor(Color.lightGray);
int y = next_row + (fontMetrics.getHeight() * (maxHeight - 1)) + fontMetrics.getDescent();
g2.draw(new Line2D.Double(pageFormat.getImageableX(),
y,
(pageFormat.getImageableY() + pageFormat.getImageableWidth()),
y));
g2.setColor(current_color);
// Return the position of the row following this one
return next_row + (fontMetrics.getHeight() * maxHeight);
public String formatObject(Object obj)
String value = (obj == null) ? "" : obj.toString();
return value; -
PSC 1210 Mac OS 10.6 Scan multiple pages into one pdf., and ink levels
Now that I upgraded my Mac OS to Snow Leopard (10.6.8), I have needed to scan on my HP all-in-one psc 1210 either from Preview or from Scan & Fax in System Preferences. Once I scan a page and that page opens up, I AM able to scan additional pages, but each becomes a separate document. The only system driver available from HP is print only and also doesn't include a utility to check ink levels. Can someone help me with these two issues? (1) how to scan multiple pages into a single pdf. doc with my configuration, and (2) how can I check ink levels
This question was solved.
View Solution.Hi C_Maier,
I can not see the available options when it is disconnected. A screenshot when it is connected would be best. I have done some research though, and believe the option to select 'save all pages to a single file' may only be available if your printer has a document feeder, and of course as you know, yours does not
I know with 10.7 and higher the option is there even with flat bed only printers. You might consider upgrading the OS.
Please click the Thumbs up icon below to thank me for responding.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
Sunshyn2005 - I work on behalf of HP -
Add grid rows in panel grid layout in adf UI page
I'm using panel grid layout in adf UI page. I need to add a dynamic grid row in panelGridLayout. Or in simple way programatically I need to add grid rows in panel grid layout in adf UI page.Timo Hahn Frank Nimphius Shay Shmeltzer-Oracle
Hi Shay,
It is a dynamic grid.
there can be one dropdown, two dropdown.... n dropdown.
Please tell me if there is any specific method to add children. -
Advanced Data Grid Grouping per Level
I'm new to flex, i'm using the advanced data grid component and i need to do different grouping for each level in the tree,i want to do right click and select which drill down is relevent for the specific level.
how can i do it? the grouping seems to be for all the tree.I'm new to flex, i'm using the advanced data grid component and i need to do different grouping for each level in the tree,i want to do right click and select which drill down is relevent for the specific level.
how can i do it? the grouping seems to be for all the tree. -
Hi,
I'm getting error as adobe Illustrator crashes while loading the multiple pages PDF file.
Please help me. Thanks in advance.Hi Monika,
I have downloaded the script to load the multiple page of pdf file.
I tried loading the multiple page PDF file via File Menu -> Scripts -> Other Script...
After executing the script file -> Browse and enter the page number - > OK
The PDF file is looks like created from word document. There are total 120 pages in this file.
PDF file size is 20 MB.
I'm still searching for the solutions. Please help me.
Thanks,
Lavprasad -
Need to print in image with good quality in multiple pages
rinting of the image display area is to small to read on some large displays
Need to restrict the image resizing in generating the print output to a minimum size (to allow it to be readable) and allow the printed output to flow into a multiple pages wide by multiple pages in length if necessary. Currently it is restricted to one page.
below is the code
public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
if (pageIndex != 0)
return NO_SUCH_PAGE;
Graphics2D g2d = (Graphics2D) g;
Rectangle2D.Double printBounds = new Rectangle2D.Double(
pageFormat.getImageableX(),
pageFormat.getImageableY(),
pageFormat.getImageableWidth(),
pageFormat.getImageableHeight()
// Print the header and reduce the height for printing
float headerHeight = printHeader(printBounds, g2d);
printBounds.y += headerHeight;
printBounds.height -= headerHeight;
// Carve off the amount of space needed for the footer
printBounds.height -= getFooterHeight(g2d);
// Print the nodes and edges
printDisplay( printBounds, g2d, 0 );
if (footer != null) {
printBounds.y += (printBounds.height + 15);
printFooter(printBounds, g2d);
return PAGE_EXISTS;
=================================
protected void printDisplay( Rectangle2D.Double printBounds, Graphics2D g2d, double margin ) {
// Get a rectangle that represents the bounds of all of the DisplayEntities
Rectangle r = null;
for (Enumeration e=displayManager.getEntitySet().getEntityEnumerati on();e.hasMoreElements();) {
DisplayEntity de = (DisplayEntity)e.nextElement();
if (r == null)
r = de.getBounds();
else
r = r.union(de.getBounds());
// Get that as doubles, rather than ints, and expand by half the margin
// height in all directions
Rectangle2D.Double entityBounds = new Rectangle2D.Double(r.x,r.y,r.width,r.height);
entityBounds.x -= margin/2;
entityBounds.y -= margin/2;
entityBounds.width += margin;
entityBounds.height += margin;
// See if height and/or width was specified
Unit specifiedSize = configuration.getHeight();
double printHeight = (specifiedSize != null) ?
specifiedSize.getValueAsPixels((int)printBounds.he ight) :
printBounds.height;
specifiedSize = configuration.getWidth();
double printWidth = (specifiedSize != null) ?
specifiedSize.getValueAsPixels((int)printBounds.wi dth) :
printBounds.width;
// Figure out the ratio of print-bounds to the entities' bounds
double scaleX = 1;
double scaleY = 1;
// See if we need to scale
boolean canExpand = configuration.expandToFit();
boolean canShrink = configuration.shrinkToFit();
if (canExpand == false && canShrink == false) {
scaleX = scaleY = configuration.getScale();
else {
if ((canShrink && canExpand) ||
(canShrink &&
(entityBounds.width > printWidth ||
entityBounds.height > printHeight)) ||
(canExpand &&
(entityBounds.width < printWidth ||
entityBounds.height < printHeight))) {
scaleX = printWidth / entityBounds.width;
scaleY = printHeight / entityBounds.height;
if (configuration.maintainAspectRatio()) { // Scale the same
if (scaleX > scaleY)
scaleX = scaleY;
else
scaleY = scaleX;
above methods am using for printing image. but in large display i cant able to read letters.
Thanks in advance
SriniYour renderer is wrong.... try this (untested):
class myCellRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
if (value!=null) {
ImageIcon icon = new ImageIcon(image); // assuming image is defined elsewhere and is accessible
setIcon(icon);
setText(value.toString());
} else {
setIcon(null);
setText("");
return this;
};o)
V.V. -
Column formatting based on grouping data value- advanced data grid
Hello Everyone,
I am using advanced data grid to display hierarchial data nested upto depth 4. I have to color the leaf nodes conditionally based on the grouped column value.
Say for Eg.,
If the data is something like
Company
Manager
Jim $4000
John $3000
Accountant
Smith $2000
Sam $3000
I have to color Jim and John based on they being a manager. In other words, how do I get Manager and Company information for the leaf rows. The data is serial to start with and I am grouping it before displaying.
Please let me know how this could be done.
Thanks
ArunOnce htmldb.oracle.com is available again, you may have a look in my demo application:
http://htmldb.oracle.com/pls/otn/f?p=31517:1
In the tab section I, you will find several examples on pop-up pages. There this conditional
displaying is included as well.
Denes Kubicek -
Advanced data grid and SummaryRow
Hello,
I've gotten the SummaryRow to work in AdvancedDataGrids in the past for performing certain functions like sum or average... but for this specific instance I want to do a summary row on non-numeric values (approved or rejected).
For instance... lets say I have a GroupingCollection in the advanced data grid and I want to group by department (this is a 1 to many with dept having 1 or more employees). At that grouped level I want to show either "approved" or "rejected"... how can i show this next to the grouped department (not as another group below the department)? See my screenshot below of my output and how I could achieve this."jim1234" <[email protected]> wrote in
message
news:g7eqkr$g6m$[email protected]..
> Ok, I know what the problem is, I just don't know a good
way to fix it.
>
> The problem is that the ArrayCollection that I use to
populate the data
> grid
> does not have data until after the initialize event is
fired. So I need
> to
> find out where/how to call the gc.refresh() method after
the
> ArrayCollection
> has data.
You're binding to it. Make sure it is bindable. -
Advanced Data Grid - Multi-Select
Good Day,
I am using an Advanced Data Grid to display data to the user. The user needs to be able to select multiple rows, and not necessarily in order. This is all fine, however, they don't want to have to hold the CTRL or SHIFT keys when selecting, and would like the mouse to act as a select/deselect for the row.
I know that I will have to extend the ADG class to handle this, but I was hoping that someone else may have done this, or has some guidance. I have never extended a class before, so I am not sure what all steps i will need to take.
Thanks!
RobsortExpertMode property
public var sortExpertMode:Boolean
By default, the sortExpertMode property is set to false,
which means you click in the header area of a column to sort the
rows of the AdvancedDataGrid control by that column. You then click
in the multiple column sort area of the header to sort by
additional columns. If you set the sortExpertMode property to true,
you use the Control key to select every column after the first
column to perform sort.
The default value is false.
So, this property simply changes HOW you do multi-column
sorting.
I submitted an enhancement request:
http://bugs.adobe.com/jira/browse/FLEXDMV-1429 -
Advance Data Grid - Flat Query Array Collection To Grouping Collection Issue
Currently I have a Coldfusion CFC returning a flat query. The query is flat but returns data with four levels. For simplicity let's say Region, Territory, Title, and Person.
I place the data into an Array Collection in Flex and then use the Advanced Data Grid (ADG) with a Grouping Collection to create a hierarchy of Region, Territory, Title. At the lowest level of the ADG I have the Person data and that data is summarized up to the Region node. The problem I am having is that sometimes I do not have any person data but have data at the Title level that can be summarized up to the Region node.
For data where the Title does not have any Person information the Title node still can be expanded to show a blank Person row. How can I prevent blank Person rows from showing up while still maintaining the ability to properly show available Person rows?
Would using an XML Collection accomplish this?Currently I have a Coldfusion CFC returning a flat query. The query is flat but returns data with four levels. For simplicity let's say Region, Territory, Title, and Person.
I place the data into an Array Collection in Flex and then use the Advanced Data Grid (ADG) with a Grouping Collection to create a hierarchy of Region, Territory, Title. At the lowest level of the ADG I have the Person data and that data is summarized up to the Region node. The problem I am having is that sometimes I do not have any person data but have data at the Title level that can be summarized up to the Region node.
For data where the Title does not have any Person information the Title node still can be expanded to show a blank Person row. How can I prevent blank Person rows from showing up while still maintaining the ability to properly show available Person rows?
Would using an XML Collection accomplish this? -
Empty pages being generated when report spans multiple pages
hi folks
I have a problem when generating my pdf form that I hope you can shed some light on.
Firstly, I have a table within a table.
Eg. For each line of Table_1, a new page must be displayed.
Then for Table_2 a list of employees with the matching criteria in line_1 of Table_1 are displayed on page 1. For the next line of Table_1, the same, and so on.
My problem comes in when there are too many employees in Table_2 to fit on a single page, they span onto the next page (as they should), but the pdf form also now displays blank pages at random.
Something like this:
Page 1
--empty
Page 2
-Table_1-Line_1
-Table_2 (lines 1 - 30 of 35)
Page 3
-Table_1-Line_1
-Table_2 (lines 31-35 of 35)
Page 4
-Table_1-line_2
-Table_2 (lines 1 - 10 of 10)
Page 5
--empty
Why the empty pages? Any help will be much appreciated.
thanks.
Also worth noting. If Table_2 doesn't span multiple pages, then I don't get the empty pages.
thanks in advance
Anton KruseHello,
it is clear why your first page is blank. That is because you set "top of next page" (tab binding) for every line of the outer table so every "section" starts on the new page. That is why even the first page starts on the second page (top of NEXT page for the first line is SECOND page).
About the last page... I have experienced problems when I used margins - when your page content is long, but not that long to break the page and you use a margin so the last row + margin should break the page, the last row is left on the last-1 page and the margin "appears" on the last page.
Hope this helps a bit, Otto -
How do I scan multiple pages into one pdf document on a HP Envy 4501 Printer
My HP Envy 4501 Printer won't let me scan multiple pages into one pdf document.
I went to "Advanced Settings", clicked on "file" and made sure that the check box next to "Create a separate file for each scanner page" was unchecked.
When I clicked the Save button it showed the page that I scanned and showed 1/1. On the right side it had options for changing the brightness and Contrast, Rotate and Crop and "Back", "Save" and "Done" buttons, but nothing about scanning another page.
Not to mention HP's Customer Support is useless!
I'd appreciate any help I can get with this problem.
Thanks,
MarkHi BH,
I see your diagram. I just scanned something. The screen that I'm looking at right now shows the preview page and the scroll box to the left of that just like in your diagram. The screen does not show the + button nor does it show the red x button under the scroll box as in your diagram. I can't see the plus sign because it is not there.
I tried re-installing the software and drivers as you suggested but that did not have any affect.
Thank you for trying to help me with this problem but it hasn't worked, therefore I can't mark the reply "Accept as Solution".
I've noticed that on HP's support forum web page there is only 1 solved request for assistance. That doesn't give me much confidence in HP.
Please reply back to this post to let me know if there is anything else that I can try or if you know someone else at HP that can help.
If I don't here back from you, I'm returning this HP Envy 4501 Printer to get my money back to use it to buy a printer from one of HP's competitors.
Thanks,
Mark
Maybe you are looking for
-
IPhone 4S - No Cellular Data Activity After Updating To iOS 8.0.2
My phone is unable to activate and/or use cellular data after updating to iOS 8. I have already installed 8.0.2 which promised to fix these issues; and it has not. Google Maps, Chrome, Safari, iMessage...none of these features work unless connected t
-
How to set a program into backgroud job
hi experts,i want to set a program into backgroud job. the original code like this: ...some statements... PERFORM FRM_SEND_MAIL USING WA_YA_LX. ...some statements... i want to set 'PERFORM FRM_SEND_MAIL USING WA_YA_LX.' into background job. is that c
-
Ways to put Multiple discoverer worksheets in a single Portlet. (10G releas
Hi all Can anybody suggest me ways to put Multiple discoverer worksheets in a single Portlet. (10G release 2) - Out of the box (no coding option) - Java Beans options Note:- the discoverer sheet portlet allows only 1 workseet. Would appreciate any po
-
I. trying to modify and/or delete some of the listings in the new Recents banner that shows up noe in iOS8
-
I bought the Pages App a couple of days ago, on my bank statement shows that Apple charged $9.99 for the app but now I'm having problems because its telling me that I owe that money.... What do I need to do?