Displaying a Grid
I need a grid that i can move objects around in
I need to have a 10 by 10 grid where 30% of the spaces are occupied by object (15% red and 15% blue). The object will only be able to stay in that square if it's neighbours are predominantly the same colour. if that is not the case than the object must be moved ot an adjacent square.
Thanks, any help would be appreciated!
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.util.Random;
import javax.swing.*;
public class ProxiGrid extends JPanel {
int[][] grid;
final int PAD = 20;
public ProxiGrid() {
grid = new int[10][10];
initializeGrid();
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
double w = getWidth();
double h = getHeight();
double xInc = (w - 2*PAD)/grid[0].length;
double yInc = (h - 2*PAD)/grid.length;
for(int j = 0; j < grid.length; j++) {
double y = PAD + j*yInc;
for(int k = 0; k < grid[j].length; k++) {
if(grid[j][k] == 0) continue;
Color color = grid[j][k] == 1 ? Color.red : Color.blue;
g2.setPaint(color);
double x = PAD + k*xInc;
g2.fill(new Rectangle2D.Double(x, y, xInc, yInc));
g2.setPaint(Color.black);
double x1 = PAD, y1, x2 = w-PAD, y2 = h-PAD;
for(int j = 0; j <= grid.length; j++) {
y1 = PAD + j*yInc;
g2.draw(new Line2D.Double(x1, y1, x2, y1));
y1 = PAD;
for(int j = 0; j <= grid[0].length; j++) {
x1 = PAD + j*xInc;
g2.draw(new Line2D.Double(x1, y1, x1, y2));
private void initializeGrid() {
Random seed = new Random();
fillSquares(1, seed);
fillSquares(2, seed);
private void fillSquares(int n, Random seed) {
int count = 0;
while(count < 15) {
int row = seed.nextInt(grid.length);
int col = seed.nextInt(grid[0].length);
if(isEmpty(row, col)) {
grid[row][col] = n;
count++;
private boolean isEmpty(int row, int col) {
return grid[row][col] == 0;
public static void main(String[] args) {
ProxiGrid test = new ProxiGrid();
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(test);
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
}
Similar Messages
-
What is the difference between list display and grid display in alv report
Hai genious
i am a new of the abap, i dont know the alv report, i have a small doubt, can u please tell me what is the main difference between list display and grid display in alv report
thanks®ards
chinnuHi ,
1. For all practical purposes, they are the same.
2. Some differences:
a) from abap coding point of view,
alv list is done with Function modules,
alv gris can also be done with FM,
but can also be done using OO concepts.
b) Alv grid (using oo concept) requires
designing the screen layout .
Hence, in one screen, we can show more
then one alv grid
(we cannot show more than
one alv list on one screen)
c) ALV grid uses ActiveX controls
present on the Presentation Server.
Hence, it consumes More Memory
on the presentation server.
d) ALV LIST is Display Only.
Whereas
ALV Grid Can Be made EDITABLE for entry purpose.
e) In alv grid, these options are possible,
but not in alv list.
without horizontal lines
without vertical lines
without cell merging during sorts
display total lines above the entries
I hope it helps.
Regards,
Mamta
Edited by: Mamta Verma on Nov 27, 2008 6:41 AM -
Reg. can we display alv grid using field groups (extracts)
Hi,
can we display alv grid using field groups (extracts). is this possible. i have to develop a blocked alv.
tnks
Yerukala SettyNo, you will need the data in an internal table to use ALV.
Cheers
Allan -
Report to display in Grid for VAL10C TC even if I dnt select any variant
Hi everybody,
I am facing the problem with VL10C trasaction code. It is displaying report in normal list if we dnt select any variant. But I want to display in grid .
I have tried through settings for managing the layout but I was invain.
If select any variant then it is displaying in grid.
But with out grid how to display the report in grid.
its an urgent issue.
eagerly waiting for reply.
Thanks and regards
JpHI,
In the Third Button of Save Layout.Check the USer Specific settings of the Report Layout and save the Varaint.This will help.
Bala.M -
hi,
i have two problems in displaying ALV grid output Using Oops.
1) How to modify the fieldcatalog after we getting a field catalog using general FM.
2) initialy it is displaying 13 fields but there are 63 fields .
eventhough we chage the layout to 63 fields it is displaying only 13 fields , these 13 fields may be different based on our selection but count of displayed fileds are same . how can display 63 fields at a time .Hi,
You can chnage using below code:
loop at gt_fieldcat.
if <gt_fieldcat-field_name> = 'FIELDNAME'.
endif.
modify gt_fieldcat.
clear gt_fieldcat.
endloop.
Make sure that all the field should not have no_out = 'X' and tech = 'X'.
Thanks,
Sriram Ponna. -
Module Pool for displaying the Grid values in Matrix format
Hi Experts,
I have one requirement which as follows,
In Module pool program i need to display the Grid Values in Matrix format i.e,
Row = Color
Column = Size
Like what we can see in Sales order or Purchase Order if you click Grid Entries Button.
Can you Please Help me out.
Thanks n Advance.
LoguHi
the sources ate the function groups WMMB and WMMA.
In a new release you should find the function module MGW_UTILITIES_MATRIX_SHELL_RA
the report RWRFMATCHARVAL is a good example
Regards
Björn -
Hide some cells while displaying ALV GRID !
Hi guyz!
Back with lill query,
While displaying ALV GRID using REUSE_ALV_GRID... FMs ,i need to hide
some cells by default, when the lists is generated.But those cells should
be availble to be displayed by the user from ALV layout settings.
Please advise
Thanks
jahanHi, Check for fm documentation.
Only relevant if layout parameter
LAYOUT-GET_SELINFOS of IMPORTING structure IS_LAYOUT is set.
Complex type for modifying information displayed on the selection dialog box:
mode: 'R' = Only entries passed in internal table
IS_SEL_HIDE-T_ENTRIES are output on
the dialog box. Selection information
obtained by the list tool by reading the
selection screen again (only if the report
is called with selection screen) are
replaced by the entries passed.
'S' = The selection information obtained by the
list tool by reading the selection screen
of the calling report again, are modified
by the entries of table
IS_SEL_HIDE-T_ENTRIES.
t_entries: Table with selection information
t_entries-mode: 'A' = Display selection information of the current
table row on the information dialog box.
'D' = Do not display selection information of the
the Select option or of parameter SELNAME
on the dialog box.
t_entries-selname: (required only if t_entries-mode = 'D')
name of Select option or parameter
The following table fields are only required if t_entries-mode = 'A'. They contain the selection information to be added.
t_entries-field: DDIC field name of the field for which selection
information is to be displayed
t_entries-table: DDIC table name of t_entries-field.
t_entries-stext: Field description on the information dialog box.
If t_entries-field and t_entries-table were
filled, this text is taken from the DDIC.
t_entries-valuf: Selection condition from-value (external format)
t_entries-valut: Selection condition to-value (external format)
t_entries-sign0: (I)nclusive (E)xclusive
t_entries-optio: All values of the option field of the Select
option are allowed.
The remaining fields are used internally and are irrelevant to the caller.
aRs -
How to display two grids in same screen using SALV Method
Hi Freinds,
Please let me know how to display two grids in same screen using SALV Method.
Thank you
Regards,
SDVUsing the same concept as described in How to dispaly Three Internal Table Data (One below another) in ALV OOPS .
All you need to add is passing your new containers as r_container parementer of factory method.
"1st one
cl_salv_table=>factory(
EXPORTING
R_CONTAINER = g_top_container
"2nd one
cl_salv_table=>factory(
EXPORTING
R_CONTAINER = g_bottom_container
Regards
Marcin -
How to retrieve Task Lists from All Subsites to the Parent Site and display in Grid view using CAML Query + object model
do u just want task list or items under task list for all subsites
for items use spsitedataquery ref
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx use recursive to get it from alll subsite under site collection
for tasklist only u can a simply use a for loop to find in all subsite
Manish Sati -
Display ALV GRID Using Dynamic Internal Table
Hi all,
I try to display ALV Grid using Dynamic Internal Table, but when i activate my program, i get an error message "DYN_TABLE" is not type-compatible with formal parameter "IT_OUTTAB". ( DYN_TABLE is my Dynamic Itab).
Anybody can help me how to passing Dynamic Itab into ALV Grid ?? Of ALV Grid only accept static Itab ??
Thanks,Hi Vijay,
It's doesn't work, and make new error "Formal parameter "IT_OUTTAB[]" does not exist. However, the parameter "IT_OUTTAB" has a similar name."
Because the method is:
CALL METHOD <ref. var. to CL_GUI_ALV_GRID>->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE = <any type (ANY)>
I_STRUCTURE_NAME = <string of type DD02L-TABNAME>
IS_VARIANT = <structure of type DISVARIANT>
I_SAVE = <var. of type CHAR01>
I_DEFAULT = <var. of type CHAR01>
IS_LAYOUT = <structure of type LVC_S_LAYO>
IS_PRINT = <structure of type LVC_S_PRNT>
IT_SPECIAL_GROUPS = <internal table of type LVC_T_SGRP>
IT_TOOLBAR_EXCLUDING = <internal table of type UI_FUNCTIONS>
IT_HYPERLINK = <internal table of type LVC_T_HYPE>
IT_ALV_GRAPHICS = <internal table of type DTC_T_TC>
CHANGING
IT_OUTTAB = <internal table>
IT_FIELDCATALOG = <internal table of type LVC_T_FCAT>
IT_SORT = <internal table of type LVC_T_SORT>
IT_FILTER = <internal table of type LVC_T_FILT>
Thanks, -
Icons no longer display in grid view in Yosemite
Hello,
All of a sudden, the icons in folders no longer display in Grid view, but only in the other kinds of view list etc.
Please, I need your help since that is the preferred method I use to display my icons
Here is a link to the screenshot of what I see for further reference:
http://monosnap.com/image/jxliJJrL8dvX8cSsLFFlRm899BqYRN
Any help would be more than appreciated! I am desperate!Right click the Application icon in the Dock.
Select "Grid" or "Automatic" under "View content as" from the menu that pops up. -
Calling smartform and displaying ALV grid in ABAP WEBDYNPRO
Hi all,
I am new to ABAP web dynpro.I ahve few custom reports which are simple ALV list reports which I now need to convert to ABAP web dynpro application .
For one particular report,based on the selection screen input,I need to display the ALV list and when I select the records from the ALV list,I need to call a smartform on clik of a push button.
My questions:
1. Im using 'REUSE_ALV_GRID_DISPLAY' FM to display the o/p in my report.Is there any similar FM in webdynpro ABAP which will display my list in ALV GRID in my web dynpro application??/
2. How to call a smartfrm in ALV grid in web dynpro??
Edited by: abap_1000 on Jan 9, 2011 6:09 PMHi,
You can search SDN, there are several posts available. Just to get some idea, you can check --
[Beginneru00B4s questions on WDA ALV;
[Reg ALV Display;
For clicking event on ALV --
[Reg Row Data fetching on click in ALV;
For ALV display on WDA --
[http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/101df93f-4b5c-2910-14aa-9eb0338c2110?quicklink=index&overridelayout=true]
Thanks.
Kumar Saurav. -
Can I filter by value which is not displayed in grid columns?
In excel it is possible to filter by value of measure which is not displayed in the report.
How can I possibly do this in Performance Point Grid? (in filter by value there I only see the measures in columns).
Please advise
NamnamiI found it is possible to filter by value by changing the MDX in the query tab.
(I filtered by certain existing value in design, then switched to Query and changed to the measure which is not displayed). I shows up correctly.
The problem is, once I change the query, I get an error when tring to connect a filter on a grid column:
"consumer parameter no-longer exists in the consumer webpart"
The grid looks "frozen"- cannot drill up / down etc.
How can I filter by value which is not displayed without loosing the ability to attach a filter to the grid?
Namnami -
REGARDING ALV BLOCK DISPLAY AND GRID DISPLAY
HI FRIENDS,
I HAVE A TROUBLE IN DISPLAYNG TWO TABLES TOGETHER IN THE GRID DISPLAY, BUT I CAN DISPLAY USING BLOCKS. I DONT WANT TO USE JOIN STATEMENT IN THE SELECT QUERY.
HELP WITH BY DISPLAYING THE RESPECTIVE CODES FOR THAT.
THANK U IN ADVANCEhi,
type-pools : slis,icon.
data : gd_repid like sy-repid.
data : d_fieldcat type slis_t_fieldcat_alv,
d_fieldcat_wa type slis_fieldcat_alv.
data : begin of itab_mara occurs 0,
matnr like mara-matnr,
ernam like mara-ernam,
end of itab_mara.
data : begin of itab_marc occurs 0,
matnr like marc-matnr,
werks like marc-werks,
end of itab_marc.
data : begin of itab_final occurs 0,
matnr like mara-matnr,
ernam like mara-ernam,
werks like marc-werks,
end of itab_final.
gd_repid = sy-repid.
loop at itab_emp.
itab_final-matnr = itab_emp-matnr.
itab_final-ernam = itab_emp-ernam.
append itab_emp.
clear itab_emp.
endloop.
d_fieldcat_wa-fieldname = 'MATNR'.
d_fieldcat_wa-seltext_l = 'material number'.
d_fieldcat_wa-col_pos = 1.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'ERNAM'.
d_fieldcat_wa-seltext_l = 'created by'.
d_fieldcat_wa-col_pos = 2.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
d_fieldcat_wa-fieldname = 'WERKS'.
d_fieldcat_wa-seltext_l = 'plant number'.
d_fieldcat_wa-col_pos = 1.
append d_fieldcat_wa to d_fieldcat.
clear d_fieldcat_wa.
call function module 'REUSE_ALV_GRID_DISPLAY'.
Reward with points if helpful. -
How to display ALV grid in a graphical display??
Hello All,
I want to display the ALV grid output in graphical format. I did not see any particular Function code or event in ALV for graphs. Hence I designed a PF status myself. But when I use the Function module "Graph_2D", it gives me an error.
Can you guys suggest which is the best Function module to display the ALV output in graphical format?
Regards,
Abhishek
P.S: Points will be awarded to the answers which will solve the issueThis piece of code is giving graphical output , u can check it in ur machine.
REPORT ZSKC_GRAPH.
data : begin of itab occurs 0,
day type i,
val type i,
end of itab.
start-of-selection.
do 5 times.
clear itab.
itab-day = sy-index.
itab-val = sy-index + ( sy-index * sy-index ).
append itab.
enddo.
CALL FUNCTION 'GRAPH_2D'
TABLES
DATA = itab
EXCEPTIONS
GUI_REFUSE_GRAPHIC = 1
OTHERS = 2
IF SY-SUBRC <> 0.
* Give some message.
ENDIF.
You just pass ur internal table to this Function module - Do you need to display column captions etc ?? In that case you will have to use GRAPH_MATRIX_2D. -
Generic function displaying alv grid for undefined structure
Hi experts,
I'm doing my first steps on abap development (Totally noob).
I'm writing some little reports based on simple selections (1 or 2 tables).
In every report, I've defined a structure (internal table) that i'm displaying with an ALV Grid.
In every report, I need to create a catalog for my structure in order to make the alv grid working.
What I would like to do is :
Create a function that receives a undefined structure (for all my reports) as a parameter.
This function sould create the catalog for the coresponding structure and call the alv grid function to display the data's contained in this structure.
The goal is : In every report, I would like to use this function to show the selected data's without taking care of catalogs, alv grid, etc...
Is it possible ?
I really don't see how I can do that... Does anybody already tried something like that ?
Thank you for your help
Regards
QuentinHi,
In this method Pass the structure name-
CALL METHOD gh_grid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = "<- here pass the structure
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT = "<-Layout variable if using layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
it_outtab = gt_line[]
it_fieldcatalog = gt_fieldcat
IT_SORT =
IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
Maybe you are looking for
-
RSS and Blogging from JSP page
I want to have RSS feed in my JSP page and Blogging as well. Possibly with RSS I can get news and Stock quotes! Does anyone have suggestions? Where can I get more info on this?
-
Travel Mangement Implementation(ECC 6)
Hi Experts, We are Implementing Travel Management for 20 company code. They have implemented HR for all company codes but for 6 company codes there is no FI Implemented they are using External system for FI. Can you please let me know how to go about
-
Incorrect CS Orders Settlement
A CS order was created with correct partner information, however with the revenue settlement in COPA, the correct partner profit center was not derived. The derived profit center is incorrect and can lead to incorrect data/figures. What are the Custo
-
I'm developing an application, which needs displaying of DSNs created in the machine on which the application is running. In some forum listings, the method given is to access the native libraries and access the drivers. I would like to know, if ther
-
Hi! I'm using a ppc g5 imac, but I have stuff happening on an older machine using system 9. How can I make my imac see the system 9 machine on the ethernet network, so I can transfer stuff between them?