473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Not A Rectangle

this is a repost of a languishing query. is there a conventional value for
"NAR" (Not A Rectangle) that Rectangle may be initialized to, sort of like
NAN for doubles?

Thanks in advance!!
Nov 15 '05 #1
5 1767
"woodBeeProgrammer" <wo***************@spamex.com> wrote:
is there a conventional value for "NAR" (Not A
Rectangle) that Rectangle may be initialized to,
sort of like NAN for doubles?


Rectangle is a reference type, so you can set it to null.

If that isn't good enough, I suppose you could inherit from Rectangle
(assuming it isn't a sealed class) and add an extra member to the derived
class to indicate whether the rectangle is initialised.

P.

--
www.CL4.org
Nov 15 '05 #2
n!
> this is a repost of a languishing query. is there a conventional value
for
"NAR" (Not A Rectangle) that Rectangle may be initialized to, sort of like
NAN for doubles?


You could use an empty rectangle to denote a 'Not A Rectangle'. If the
x,y,width and height properties are zero, the IsEmpty property returns true.

n!
Nov 15 '05 #3
umm, i believe Rectangle is a value type (struct System.Drawing.Rectangle).

the obvious initialization of X=Y=Length=Height= 0 is problematic because it
is potentially a reasonable value (i think).

a better NAR choice would be something like Length = -1, which i can do for
myself, but i'd think this must be a standard problem with a standard
answer..

yes?? no??
"Paul E Collins" <fi******************@CL4.org> wrote in message
news:br**********@titan.btinternet.com...
"woodBeeProgrammer" <wo***************@spamex.com> wrote:
is there a conventional value for "NAR" (Not A
Rectangle) that Rectangle may be initialized to,
sort of like NAN for doubles?


Rectangle is a reference type, so you can set it to null.

If that isn't good enough, I suppose you could inherit from Rectangle
(assuming it isn't a sealed class) and add an extra member to the derived
class to indicate whether the rectangle is initialised.

P.

--
www.CL4.org

Nov 15 '05 #4
There is really nothing called an "invalid" rectangle. It depends on
interpretation.

However, the framework provides IsEmpty that will return true if x, y, width
and height are all 0s.

Negative values are perfectly valid values for Width and height of a
rectangle (imagine you're drawing a rband rectangle - going past the left of
the starting point will yeild a rectangle with negative width)

-vJ

"woodBeeProgrammer" <wo***************@spamex.com> wrote in message
news:vt************@corp.supernews.com...
this is a repost of a languishing query. is there a conventional value for "NAR" (Not A Rectangle) that Rectangle may be initialized to, sort of like
NAN for doubles?

Thanks in advance!!

Nov 15 '05 #5
It's a value type. However, you can create a boxed reference of type object,
and set the reference to null or to a valid triangle. Kinda nasty if you
take into account the boxing perf hits. Best bet is to set a no-area
rectangle value (like 0,0,0,0) to mean "not-a-rectangle".

-Rob Teixeira [MVP]

"Paul E Collins" <fi******************@CL4.org> wrote in message
news:br**********@titan.btinternet.com...
"woodBeeProgrammer" <wo***************@spamex.com> wrote:
is there a conventional value for "NAR" (Not A
Rectangle) that Rectangle may be initialized to,
sort of like NAN for doubles?


Rectangle is a reference type, so you can set it to null.

If that isn't good enough, I suppose you could inherit from Rectangle
(assuming it isn't a sealed class) and add an extra member to the derived
class to indicate whether the rectangle is initialised.

P.

--
www.CL4.org

Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Steven T. Hatton | last post by:
The following may strike many of you as just plain silly, but it represents the kind of delelima I find myself in when trying to make a design decision. This really is a toy project written for...
3
by: cjeffwang | last post by:
I am doing examples in "JavaScript: the Definitive Guide." For Example 8-1, a rectangle constructor function, how do I print/write the rectagle (x,y)? Here is the JavaScript program: ...
6
by: kimos | last post by:
hi all, how to calculate the intersection of 2 rectangle a rectangle is the following: Rectangle makeRectangle (Point lowerLeft, Point upperRight) { Rectangle r;
3
by: | last post by:
I am having a hard time understanding the logic behind the Rectangle object. My problem has to do with the way the rectangle treats the "Width" property. For example, take the following rectangle...
4
by: Colin McGuire | last post by:
Hi, this is a really simple question I have been banging my head on a brick wall over. The program below changes the background colour of a form depending on whether the cursor is inside a...
5
by: DazedAndConfused | last post by:
I have a rectangle around text that I want to fill in with color. I do not know the height of the rectangle until I actually go through and draw out the text. Is there a way of filling in the...
7
by: Florian Haag | last post by:
Hello, I'm trying to compile a programme which compiles fine under Linux; I'm trying it with MinGW G++ 3.4.2: Component.h: #ifndef COMPONENT_H_ #define COMPONENT_H_
10
by: sklett | last post by:
I have a situation where I'm getting in Image that has a gray (solid, same color) background with a smaller white rectangle inside. The position is not always the same. What I need to do is...
4
by: RobinS | last post by:
I am drawing a rectangle on a picture that has already been drawn on the graphics area (a user control). It works something like this: //in the MouseDown event m_isDragging = true; m_oldX =...
1
by: kummu4help | last post by:
hi, i want to draw rectangle based on mousedrag event. if user dragging the mouse, then the rectangle on the applet should increase or decrease basing on current mouse coordinates. i have the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.